M. Javad Mohebbi
M. Javad Mohebbi

Reputation: 425

npm is broken and i can not run any npm command

My npm is broken and I could not run any npm command.

$ 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

Versions:

$ node -v
v11.0.0

$ nodejs -v
v10.13.0

Following npm command gave this error:

$ 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)

Why node and nodejs has different versions and npm -v gave same error.

Upvotes: 16

Views: 16872

Answers (6)

Zubair1
Zubair1

Reputation: 2780

For me on Windows 10, what worked was: I deleted node_modules directory under the installation folder but doing that alone did not work, I also used the installer to repair the installation and after that all was good again, hope that helps someone else..

Upvotes: 1

dhinesh
dhinesh

Reputation: 4764

In windows i was getting the same error

log.progressEnabled = log.gauge.isEnabled()

npm version is 6.13.4, i installed the @angular/cli for MVC development with asp.net core with angular.

I changed the 57 line from log.js C:\Users\<>\AppData\Roaming\nvm\v6.9.5\node_modules\npm\node_modules\npmlog\log.js

from

log.progressEnabled = log.gauge.isEnabled() to

log.progressEnabled = log.gauge.isEnabled

and npm started to work.

Upvotes: 5

dixhom
dixhom

Reputation: 3035

For Windows, download an installer from the official website, run it and at the end of the installation process, choose "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."

I had the same issue and this fixed it.

Upvotes: 1

PSS
PSS

Reputation: 39

For windows, delete node_modules from the following path - C:\Program Files\nodejs\node_modules

Upvotes: 3

M. Javad Mohebbi
M. Javad Mohebbi

Reputation: 425

I removed /usr/local/lib/node_modules/ directory and everything works correctly:

sudo rm -rfv /usr/local/lib/node_modules/

Hope it will help others ;-)

Upvotes: -3

Alex Taylor
Alex Taylor

Reputation: 8823

You're facing this issue. The short solution seems to be:

Delete node_modules/npm and then run yarn install again.

There are other solutions in the issue comment thread.

Upvotes: 12

Related Questions