npm 坏了,我不能 运行 任何 npm 命令
npm is broken and i can not run any npm command
我的 npm 坏了,我无法 运行 任何 npm 命令。
$ type npm
npm is hashed (/usr/local/bin/npm)
$ type node
node is hashed (/usr/local/bin/node)
$ type nodejs
nodejs is hashed (/usr/bin/nodejs)
$ uname -a
Linux mj-lp-mint 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
版本:
$ node -v
v11.0.0
$ nodejs -v
v10.13.0
以下 npm 命令给出了这个错误:
$ sudo npm install npm -g
/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:57
log.progressEnabled = log.gauge.isEnabled()
^
TypeError: log.gauge.isEnabled is not a function
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:57:33)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
at Module.require (internal/modules/cjs/loader.js:643:17)
at require (internal/modules/cjs/helpers.js:22:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:22:13
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)
为什么 node 和 nodejs 有不同的版本并且 npm -v 给出了相同的错误。
你面对的是this issue。简短的解决方案似乎是:
Delete node_modules/npm
and then run yarn install
again.
问题评论线程中还有其他解决方案。
我删除了 /usr/local/lib/node_modules/ 目录,一切正常:
sudo rm -rfv /usr/local/lib/node_modules/
希望对其他人有所帮助;-)
对于 windows,从以下路径删除 node_modules - C:\Program Files\nodejs\node_modules
对于Windows,从官方网站下载一个安装程序,运行它,在安装过程结束时,选择"Automatically install the necessary tools. Note that this will also install Chocolately. The script will pop-up in a new window after the installation completes."
我遇到了同样的问题,这解决了它。
在 windows 我遇到了同样的错误
log.progressEnabled = log.gauge.isEnabled()
npm 版本是 6.13.4,我安装了 @angular/cli 用于 MVC 开发,asp.net 内核和 angular。
我从 log.js 更改了 57 行
C:\Users\<>\AppData\Roaming\nvm\v6.9.5\node_modules\npm\node_modules\npmlog\log.js
来自
log.progressEnabled = log.gauge.isEnabled() 至
log.progressEnabled = log.gauge.isEnabled
npm 开始工作了。
对我来说 Windows 10,有效的是:
I deleted node_modules directory under the installation folder
但是单独这样做是行不通的,I also used the installer to repair the installation
之后一切又好了,希望能帮助别人..
我的 npm 坏了,我无法 运行 任何 npm 命令。
$ type npm
npm is hashed (/usr/local/bin/npm)
$ type node
node is hashed (/usr/local/bin/node)
$ type nodejs
nodejs is hashed (/usr/bin/nodejs)
$ uname -a
Linux mj-lp-mint 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
版本:
$ node -v
v11.0.0
$ nodejs -v
v10.13.0
以下 npm 命令给出了这个错误:
$ sudo npm install npm -g
/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:57
log.progressEnabled = log.gauge.isEnabled()
^
TypeError: log.gauge.isEnabled is not a function
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:57:33)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
at Module.require (internal/modules/cjs/loader.js:643:17)
at require (internal/modules/cjs/helpers.js:22:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:22:13
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)
为什么 node 和 nodejs 有不同的版本并且 npm -v 给出了相同的错误。
你面对的是this issue。简短的解决方案似乎是:
Delete
node_modules/npm
and then runyarn install
again.
问题评论线程中还有其他解决方案。
我删除了 /usr/local/lib/node_modules/ 目录,一切正常:
sudo rm -rfv /usr/local/lib/node_modules/
希望对其他人有所帮助;-)
对于 windows,从以下路径删除 node_modules - C:\Program Files\nodejs\node_modules
对于Windows,从官方网站下载一个安装程序,运行它,在安装过程结束时,选择"Automatically install the necessary tools. Note that this will also install Chocolately. The script will pop-up in a new window after the installation completes."
我遇到了同样的问题,这解决了它。
在 windows 我遇到了同样的错误
log.progressEnabled = log.gauge.isEnabled()
npm 版本是 6.13.4,我安装了 @angular/cli 用于 MVC 开发,asp.net 内核和 angular。
我从 log.js 更改了 57 行 C:\Users\<>\AppData\Roaming\nvm\v6.9.5\node_modules\npm\node_modules\npmlog\log.js
来自
log.progressEnabled = log.gauge.isEnabled() 至
log.progressEnabled = log.gauge.isEnabled
npm 开始工作了。
对我来说 Windows 10,有效的是:
I deleted node_modules directory under the installation folder
但是单独这样做是行不通的,I also used the installer to repair the installation
之后一切又好了,希望能帮助别人..