Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 591
M. Javad Mohebbi Avatar asked Nov 13 '18 06:11

M. Javad Mohebbi


People also ask

Why npm command is not working?

On Windows, you may face the “npm command not found” error if the path to nodejs and npm are not added to your path variable. To fix this, locate the path to nodejs and npm binaries. The command above should add the specified directory to the path variable.

How do I force npm to run?

Run npm update -g npm. Execute this command by running the command prompt as Administrator npm install -g windows-build-tools. Run npm install inside the project folder where the package. json file is located, if it doesn't work run: npm install --force.

How do I fix npm run start error?

To solve the npm ERR! Missing script: "start" error, make sure to add a start command to the scripts object in your package. json file and open your shell or IDE in the root directory of your project before running the npm start command.


1 Answers

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.

like image 165
Alex Taylor Avatar answered Oct 06 '22 18:10

Alex Taylor