NPM wont run due to EEXIST error

2020-06-12 02:31发布

No matter what I do with npm, remove it, re-install it, re-hash, etc, i still get this error when I try to run anything related to npm:

prompt$  npm

------

npm ERR! EEXIST, mkdir '/usr/local/bin/npm'
File exists: /usr/local/bin/npm
Move it away, and try again. 

What is the problem and how do I fix it?

I've deleted:

/usr/local/bin/node
/usr/local/bin/npm
~/.npm

then reinstalled. still receiving the same error.

标签: node.js npm
1条回答
做自己的国王
2楼-- · 2020-06-12 03:21

I can only suggest a complete wipe of node.js and npm and reinstall. Fortunately node and npm are fairly lightweight packages so this is not too onerous.

I know you said you have reinstalled, but I suggest you manually remove all the folders that it uses to store information, in case some corrupted file is being left that is causing this. A guide to all the folder npm uses is found here:

https://www.npmjs.org/doc/files/npm-folders.html

Some configuration files are also used:

https://www.npmjs.org/doc/files/npmrc.html

This document has the following configuration files that might be relevant to issues that affect all uses of npm:

  • per-user config file (~/.npmrc)
  • global config file (${HOME}/.npm-packages/npmrc)
  • npm builtin config file (/path/to/npm/npmrc)

Other people commenting on this post have found success removing the ~/.npmrc file

If you are running on an un*x like platform, like OSX or Linux which support bash - I would recommend node version manager. This allows you to run multiple versions of node and npm - and you can can remove and reinstall versions completely.

https://github.com/creationix/nvm

查看更多
登录 后发表回答