Any package installed by npm is invalid

  bin vi npm
  bin npm install npm@latest -g
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "npm@latest" "-g"
npm ERR! node v6.8.0
npm ERR! npm  v3.10.8
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module "realize-package-specifier"
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/local/bin/npm-debug.log
  bin npm -v
3.10.8
  bin node -v
v6.8.0
  bin

npm installs no dependent packages, but both npm and node are OK. Changing the domestic Taobao image is also invalid.

cannot upload the picture, paste the code.

node and npm, installed through the pkg installation package were reinstalled today, May 18, and still reported an error. What a day, dog

WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp/8.11.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp/8.11.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp/8.11.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp/8.11.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp/8.11.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp/8.11.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp/8.11.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp"
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp/8.11.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/mip-cli/node_modules/utf-8-validate/.node-gyp"

Mar.16,2021

http://www.cnblogs.com/xxcang.


change the node version


npm is broken, need to reinstall node


just encountered this problem. If you use n packages to manage node versions, be sure to add sudo, that is, sudo n when switching, otherwise, although node-v displays normally, the install command will not be used


:
sudo chmod -R 777 /var/root

npm install koa  -g --unsafe-perm

npmnoderoot
Menu