zoukankan      html  css  js  c++  java
  • 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了

  • 相关阅读:
    Android_Spinner_example
    23.pyspider安装
    22.Windows及linux下gerapy使用
    21.scrapy爬虫部署
    12.利用kakatips对网站数据信息监控
    11.启信宝数据二次筛选解密(字符串的分割与拼接及正则匹配)-2
    10.Ubuntu操作系统及python2.7、3.5 exe
    9.数据库多表一起查询
    8.代理ip使用
    7.阿布云代理服务器试用
  • 原文地址:https://www.cnblogs.com/walkerwang/p/4206978.html
Copyright © 2011-2022 走看看