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了

  • 相关阅读:
    php RabbitMQ使用
    phalcon: 开启模板缓存和缓存路径
    phalcon:整合官方多模块功能,方便多表查询
    mysql: 模糊查询 feild like keyword or feild like keyword , concat(feild1,feild2,feild3) like keyword
    php的http数据传输get/post...
    java大数字操作:BigInteger,BigDecimal(浮点型)
    DecimalFormat数据格式函数
    MySQL比like语句更高效的写法locate position instr find_in_set
    mysql中使用instr替换like
    mysql中的多行查询结果合并成一个
  • 原文地址:https://www.cnblogs.com/walkerwang/p/4206978.html
Copyright © 2011-2022 走看看