NPM:没有这样的文件或目录 [英] NPM: no such file or directory

查看:165
本文介绍了NPM:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Ubuntu 16.04我删除了 NPM 以安装旧版本.(我不能完全命令我使用的).现在我无法再次安装它.npm -v 输出:bash:/usr/bin/npm:/usr/bin/nodejs: bad interpreter: No such file or directorywhich npm 输出:/usr/bin/npm

I'm using Ubuntu 16.04 I removed NPM in order to install older version. (I can't exactly command which I used). now I can't install it again. npm -v output: bash: /usr/bin/npm: /usr/bin/nodejs: bad interpreter: No such file or directory which npm output: /usr/bin/npm

curl -L http://npmjs.org/install.sh |须藤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

UPD: Solved. Remove node/nodejs/npm completely and remove all relative folders a then reinstall via NVM helped. https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps

推荐答案

安装 nodejs 的更好方法是通过 nvm.在这里你可以在一台机器上安装/使用多个版本的 nodejs.

Better way to install nodejs is via nvm. Here you can install/use multiple version of nodejs in a machine.

https://github.com/creationix/nvm

然后

nvm install $vesionNo

nvm use $versionNO

// for default 

nvm alias default node

这篇关于NPM:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆