Update npm installed packages - npm ERR! code EINVALIDPACKAGENAME

Viewed 2297

I'm trying to update my node modules globally. I'm using this command

sudo npm update -g 

but it will produce thise error in terminal

npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name ".DS_Store": name cannot start with a period

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/dev/.npm/_logs/2021-04-24T15_59_25_014Z-debug.log

I think that the command will scan the folder and find macOS .DS_Store file.

How I can fix this?

3 Answers

for me doing this solve my problem :

find /usr/local/lib/node_modules/ -name '.DS_Store' -type f -delete 

It search all .DS_Store and remove it in the global node_modules folder ( on Mac )

I solved the same issue for Mac OS Monterey using this

find `npm list -g | head -1` -name '.DS_Store' -type f -delete

You can try this one,

sudo npm install --global npm

I think this is going to work for you

Related