How to npm audit global packages
# Without installing the package locally, using npx
npx npm-check-updates -g
# otherwise, install and update on occasion
npm install -g npm-check-updates
# Then check outdated global packages:
ncu -g
I found an answer to your question:
- go to your global npm folder
npm init
just keep pressing enter to the questions, ornpm init -y
so it is populated with default values. That'll give you a package.json that npm audit needs and automatically add what's in your node_modules to it.npm i --package-lock-only
will install if needed and add package-lock.json (required by npm audit).- run
npm audit
:)
To find your global npm folder just run npm
it'll print it out at the end.
It's good to keep them up-to-date.
That's not really auditing, but with few as possible global packages, this should be fine enough.
there is npm-check-updates or alternatively npm-check
npm install -g npm-check-updates
check outdated global packages:
ncu -g
OR
as recommended by @pldg via npx
npx npm-check-updates -g
OR
as recommended by @wheredidthatnamecomefrom
npx npm-global-audit
this is a script running with yarn. it does a temporary copy of your current global packages. see more on their github.