【发布时间】:2018-05-15 12:23:30
【问题描述】:
我使用的是 Ubuntu 16.04
我删除了 NPM 以安装旧版本。 (我不能完全命令我使用的命令)。
现在我无法再次安装它。
npm -v 输出:bash: /usr/bin/npm: /usr/bin/nodejs: bad interpreter: No such file or directory
which npm 输出:/usr/bin/npm
curl -L http://npmjs.org/install.sh | sudo sh
输出:
`install npm@latest
fetching: https://registry.npmjs.org/npm/-/npm-5.5.1.tgz
module.js:544
throw err;
^
Error: Cannot find module '/tmp/npm.9881/package/bin/read-package-json.js'
at Function.Module._resolveFilename (module.js:542:15)
at Function.Module._load (module.js:472:25)
at Function.Module.runMain (module.js:682:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:613:3
up to date in 0.059s
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
+ npm@5.5.1
added 1 package in 1.907s
It worked`
UPD:已解决。 完全删除 node/nodejs/npm 并删除所有相关文件夹,然后通过 NVM 重新安装帮助。 https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps
【问题讨论】: