Friday, October 21, 2022

[FIXED] How to npm audit global packages

Issue

As stated in the official npm documentation you can manually run npm audit on locally installed packages, which must have both package.json and package-lock.json files.

Globally installed packages doesn't have package-lock.json, if you run an audit it will trow an error: npm ERR! code EAUDITNOLOCK

How can I run npm audit on all globally installed packages?


Solution

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.



Answered By - André Kelling
Answer Checked By - Willingham (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.