npm issue after update - node.js

After update npm i cannot use npm install when i run
npm install
i've got
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './lib/extract-stream.js'
The location of extract-stream.js is /usr/local/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js
If i run
/usr/local/bin/npm install # IT WORKS!
when i run
which npm
# output: {my_home_path}/.npm-global/bin/npm
and when i run
npm -v
# output: 6.7.0
/usr/local/bin/npm -v
# output 6.5.0
How can i fix this issue?

brew uninstall --force node
sudo rm -rf /usr/local/lib/node_modules
brew install npm
Worked just fine

First delete the file 'composer.lock.json' and run rm -rf node_modules to remove the node_modules folder. After this try to re-install npm with npm install.
Note: if you get this error node_modules/.bin/npm: No such file or directory. Run hash -r and after this npm install.

Related

I am trying to install node locally following error occurs. I tried reinstalling node several times but still it shows error

I get this error when I try to install node
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\lenovo\AppData\Roaming\npm-cache\_logs\2020-08-29T13_30_35_085Z-debug.log
try this first before installing node.
sudo npm cache verify
sudo npm cache clean --force
After installing verify your installation:
node --version
several things you can try are following
sudo npm cache clean --force
trying changing ownership of npm and try npm latest
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib
sudo chown -R $(whoami) /usr/local/bin
npm install -g npm#latest
give it a try by clearing up the proxy, maybe you're behind proxy
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/
Lately i would like to recommend you to use the NVM package. it is not the solution to your answer directly but its a great way to manage and have different node/npm environments
https://davidwalsh.name/nvm

npm is not updated in mac

I am using ios and installed npm few days back. Its current version is 5.6.0. Now, I want to update npm.
I am using the following steps to update npm:
I opened the terminal, wrote npm -v into terminal and looked into the current version of npm with is 5.6.0 as for now.
Then, I wrote npm update -g in terminal to update the current version of npm but it is showing the following error:
npm ERR! path /usr/local/lib/node_modules/npm/node_modules/cacache/node_modules/ssri
I had the same prob,
Go to your root
Run which npm and see the root, I believe it will be "/usr/local/bin/npm"
Stay on your root and try to run npm install -g npm#latest
I bet you get "missing permissions..."
Stay on your root and run the command: (to give permissions) sudo chown -R $USER /usr/local/lib/node_modules
And then run: npm install -g npm#latest
Now it should work, please try to run npm -v and see if it changed.
Goodluck :)

npm install -g npm is not updating

I cannot seem to update npm with npm install:
$ npm -v
5.6.0
$ sudo npm install -g npm#latest
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
+ npm#5.7.1
updated 1 package in 11.905s
$ npm -v
5.6.0
What's the output of your which npm, I bet it is not /usr/bin/npm.
UPDATE:
So yours' at /usr/local/bin/npm, but the npm you just updated is at /usr/bin/npm. See the line /usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js for the hint.
Remove the installation at /usr/local/bin/npm and you'll be fine.
If you don't know how to do that, simply do
sudo rm /usr/local/bin/npm
Use hash -r to make bash clear its cache and look at the path again for latest npm path.
I had noted that after installing the update, I have the re-login to the shell too see the updated npm version. Not sure why some ppl don't have to do this, but in my case, that's what I had to do.
I had the same prob,
Go to your root
Run which npm and see the root, I believe it will be "/usr/local/bin/npm"
Stay on your root and try to run npm install -g npm#latest
I bet you get "missing permissions..."
Stay on your root and run the command: (to give permissions)
sudo chown -R $USER /usr/local/lib/node_modules
And then run:
npm install -g npm#latest
Now it should work, please try to run npm -v and see if it changed.
Goodluck :)
Npm will always use the version of npm installed with node. If you are running node update node first running:
$ sudo npm install -g n
And to install the latest stable node release)
$ sudo n latest
And then check your npm version again - it should be updated. Good luck! :)

Different version of npm when using sudo?

when I tried to update npm, I found that command returns Permission deny:
npm install npm -g
Then I tried:
sudo npm install npm -g
Then npm has been updated, but when I tried npm -v and sudo npm -v, they show different version:
npm -v //3.10.10
sudo npm -v //5.1.0
How can I make them always in the same version? It also happened on command 'node -v'. I am using fedora.

Why is my npm not updating to 3.7.2 from 2.14.12?

I have installed node from node's website. By default I have got npm version 2.14.12. Now I want to update npm to 3. I am doing this -
$ npm -v
2.14.12
$ sudo npm install npm#latest -g
/Users/sudiptasen/.node/bin/npm -> /Users/sudiptasen/.node/lib/node_modules/npm/bin/npm-cli.js
npm#3.7.2 /Users/sudiptasen/.node/lib/node_modules/npm
$ npm -v
2.14.12
Even I have tried, sudo npm update npm -g, sudo npm install npm#3.7.2 -g but none of these working either.
What am I missing?
Now this may not work for you because I was already on npm 3.5.3, but try running:
npm install -g npm (with sudo in front if need be).
By running that I was able to update to 3.7.2.
I just had to create a symlink over my default npm.
sudo ln -s /Users/sudiptasen/.node/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

Resources