Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM: no such file or directory

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 | sudo sh

Output:

`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
+ [email protected]
added 1 package in 1.907s
 It worked`

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

like image 701
Nikita Yunoshev Avatar asked Dec 01 '17 11:12

Nikita Yunoshev


People also ask

Can't open npm No such file or directory?

If you ever get this error, the hotfix is to follow these steps: delete node-modules folder. run command npm cache clean --force. run command npm install.

How do I fix error Enoent No such file or directory open?

Delete package-lock. json and the node_modules folder, then run npm install again. and then re-deleting the above files and re-running npm install . Worked for me!


1 Answers

I solved it using the following simple steps in my ubuntu 18.04

  1. run which npm
  2. run hash -r
  3. run npm -v
like image 159
Zekarias Taye Hirpo Avatar answered Oct 20 '22 10:10

Zekarias Taye Hirpo