无法使用 npm 安装/卸载任何东西 [英] Unable to install/ uninstall anything using npm

查看:104
本文介绍了无法使用 npm 安装/卸载任何东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习关于学习 npm 的教程,但即使是最简单的指令也有问题.

I'm working through a tutorial about learning npm, but am having trouble with even the simplest instructions.

基本上给出的第一条指令是在全局安装 node-dev 包,使用终端行:sudo npm install -g node-dev.不幸的是,这会抛出一个错误:

Basically the first instruction given was to install the node-dev package globally, using the Terminal line: sudo npm install -g node-dev. Unfortunately, this spits out an error:

npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './access-error.js'

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/samlegros/.npm/_logs/2019-02-26T00_36_39_572Z-debug.log

经过一些谷歌搜索和挖掘,似乎对我的情况没有任何作用.所以我想我会尝试完全删除并重新安装 npm 以从头开始(我曾与 npm 合作过一段时间,所以当时可能有些事情搞砸了).

After some Googling and digging, nothing seemed to work for my case. So I thought I would try fully removing and reinstalling npm to start with a clean slate (I had worked with npm a while back, so maybe something messed up back then).

即使通过官方 npm-removal 文档,我仍然得到类似的错误!我什至无法正确删除 npm...

Even going through the official npm-removal documentation, I still get a similar error! I can't even remove npm properly...

npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './access-error.js'

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/samlegros/.npm/_logs/2019-02-26T00_38_40_865Z-debug.log

任何帮助将不胜感激.几个月来我尝试了几个 npm 教程,但它们总是导致我永远不知道如何克服的错误,非常令人沮丧:(

Any help would be deeply appreciated. I've tried several npm tutorials over the months and they always result in errors that I just never know how to overcome, very discouraging :(

(错误日志,如果有帮助)

(error log, if that helps)

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'uninstall',
1 verbose cli   'npm',
1 verbose cli   '-g' ]
2 info using npm@6.8.0
3 info using node@v8.11.1
4 verbose stack Error: Cannot find module './access-error.js'
4 verbose stack     at Function.Module._resolveFilename (module.js:547:15)
4 verbose stack     at Function.Module._load (module.js:474:25)
4 verbose stack     at Module.require (module.js:596:17)
4 verbose stack     at require (internal/module.js:11:18)
4 verbose stack     at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/install/exists.js:4:19)
4 verbose stack     at Module._compile (module.js:652:30)
4 verbose stack     at Object.Module._extensions..js (module.js:663:10)
4 verbose stack     at Module.load (module.js:565:32)
4 verbose stack     at tryModuleLoad (module.js:505:12)
4 verbose stack     at Function.Module._load (module.js:497:3)
4 verbose stack     at Module.require (module.js:596:17)
4 verbose stack     at require (internal/module.js:11:18)
4 verbose stack     at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/install/check-permissions.js:8:14)
4 verbose stack     at Module._compile (module.js:652:30)
4 verbose stack     at Object.Module._extensions..js (module.js:663:10)
4 verbose stack     at Module.load (module.js:565:32)
5 verbose cwd /path/to/tutorial/
6 verbose Darwin 18.2.0
7 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "uninstall" "npm" "-g"
8 verbose node v8.11.1
9 verbose npm  v6.8.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module './access-error.js'
12 verbose exit [ 1, true ]

推荐答案

我只是从我的 Mac 中删除了 Node.js 并重新安装了它,效果很好.

I simply removed Node.js from my Mac and reinstalled it, that worked.

用于删除Node.js的命令:sudo rm -rf/usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}

现在一切正常.

这篇关于无法使用 npm 安装/卸载任何东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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