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了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值