bash: /usr/bin/npm: No such file or directory

一个整得很烂了的Ubuntu服务器, 各种问题乱出. npm老是升不到最新版(一直显示1.4),于是我干脆删了, 结果再去装却装不上了, 如果用apt-get install npm安装, 就得到如下错误:

The following packages have unmet dependencies:
npm : Depends: nodejs but it is not going to be installed
   Depends: nodejs-dev
   Depends: node-request but it is not going to be installed
   Depends: node-mkdirp but it is not going to be installed
   Depends: node-minimatch but it is not going to be installed
   Depends: node-semver but it is not going to be installed
   Depends: node-ini but it is not going to be installed
   Depends: node-graceful-fs but it is not going to be installed
   Depends: node-abbrev but it is not going to be installed
   Depends: node-nopt but it is not going to be installed
   Depends: node-fstream but it is not going to be installed
   Depends: node-rimraf but it is not going to be installed
   Depends: node-tar but it is not going to be installed
   Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

官网居然只提供这种方法,结果发现在其github主页上提供的方法是: curl -L https://npmjs.com/install.sh | sh 成功.

仍然不能用:

npm -v
bash: /usr/bin/npm: No such file or directory

一通乱搜, 对着各种解决方法乱试, 也没真正解决,那只有自己思考一下了:

  1. npm既然装上了,那么装到哪去了(找到了)
  2. 直接到安装目录执行(成功了)
  3. 那么就软链一下试试(成功了)
    root@walker:~# find / -name "npm-cli.js"
    /root/.node/lib/node_modules/npm/bin/npm-cli.js
    root@walker:~# /root/.node/lib/node_modules/npm/bin/npm-cli.js -v
    2.1.17
    root@walker:~# ln -s /root/.node/lib/node_modules/npm/bin/npm-cli.js /usr/bin/npm
    root@walker:~# npm -v
    2.1.17

p.s. 虽然npm正常工作了,最后发现npm install一个包都下不下来, 执行了一句npm cache clean,貌似就OK了

你可能感兴趣的:(bash: /usr/bin/npm: No such file or directory)