How to fix this Error -npm - node.js

I tried to install npm and I got the following error.
I already removed npm and reinstall it again, but I again got the following error:
npm ERR! Linux 4.15.0-30-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! vx-leave-system#0.0.1 start: `node ./tools/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vx-leave-system#0.0.1 start script 'node ./tools/server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vx-leave-system package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./tools/server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs vx-leave-system
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls vx-leave-system
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/seelan/Documents/vx-leave-system/npm-debug.log
How can I fix this?

On ubuntu 18.04 following steps saved me
To remove the distro-stable version, type the following:
sudo apt remove nodejs
This command will remove the package and retain the configuration files.
sudo apt purge nodejs
As a final step, you can remove any unused packages that were automatically installed with the removed package:
sudo apt autoremove
Refresh your local package index by typing:
sudo apt update
Enable the NodeSource repository by running the following command
(optinal) If you need to install another version, for example 14.x, just change setup_12.x with setup_14.x
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
Once the NodeSource repository is enabled, install Node.js and npm by typing:
sudo apt install nodejs
Verify that the Node.js and npm were successfully installed by printing their versions:
node --version (v12.18.4)
npm --version (6.14.6)

It seems to me that you're running a newer version of Node, but an outdated version of NPM.
You can do either of the following:
Try the latest stable version of NPM:
You can upgrade to the latest version of npm using: npm install -g npm#latest
Uninstall Node form your machine completely, go to their website and install the latest stable Node version. NPM comes with it.

I faced this issue too today and the problem was caused by an upgrade in my node and npm version. Guess my project dependencies were still running on older versions of node and npm
I fixed it by deleting the node_modules folder and run
npm install
I hope this helps

This looks like a permissions issue in your home directory. To reclaim ownership of the .npm directory execute:
sudo chown -R $(whoami) ~/.npm

Check the updates of dependencies
npm outdate
Run the next command to update dependencies
npm update

Remove the path folder directory C:\Users\ACER\AppData\Local**\npm-cache_logs\2021-12-29T13_41_22_984Z-debug-0.log**
and then run this command in your CLI npm install -g npm#latest
this works with you

Related

npm install always gives 'Your cache folder contains root-owned files, due to a bug in npm previous versions of npm which has since been addressed.'

I am currently using Ubuntu 18.04.4 and I am trying to install something using npm install but it always gives the error below. I tried other aliases as well (npm i, npm add) but the error persists.
npm install
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path /home/dell/.npm/_cacache/content-v2/sha512/14/21/2143fe2b135cd8bfdad85c9c3f9ac46ab279a58dee631cfea1b9678167bd388d44f2d36739019c96ba3a4c4756b1ea6570f4dc8931fb8ad8230359521f80
npm ERR! errno -1
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1001:1001 "/home/dell/.npm"
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dell/.npm/_logs/2020-07-30T17_16_58_257Z-debug.log
When I run the sudo chown -R 1001:1001 "/home/dell/.npm" command, it does nothing, and the error remains when I run npm install again. I have also searched StackOverflow and other platforms for the answer, but no solution seems to solve this problem.
P.S: My node version is 12.18.3 and npm version is 6.14.6.
If someone can help me resolve this, I would really appreciate it!
I had problem with create-react-app. Solve it using yarn.
yarn global remove create-react-app
then
yarn global add create-react-app
and
create-react-app MyApp

How to solve npm ERR! code ERR_INVALID_OPT_VALUE

I went to install nodejs and npm on Debian9 like this with the root account because npm is not included in the legacy debian package :
curl -sL https://deb.nodesource.com/setup_8.x | bash -
.../...
## Run `apt-get install nodejs` (as root) to install Node.js v8.x and npm
:~#
:~# apt-get install -y nodejs
Now I would like to install some module with npm or to do the update of npm and I've got this error message
:~# npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.
:~# npm install -g npm
npm ERR! code ERR_INVALID_OPT_VALUE
npm ERR! The value "4294967295" is invalid for option "family"
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-03-29T11_17_37_357Z-debug.log
Here the link to the debug log file : Justpasteit
Thanks for any help

Unable to upgrade npm from 1.4.28 to latest (2.2)

I'm using stable version of node on Ubuntu 14.04. (installed via PPA) When I was trying to upgrade some packages like yo, I got the error below:
npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your version of node/npm: yo#1.4.2
npm ERR! notsup Required: {"node":">=0.10.0","npm":">=2.1.0"}
npm ERR! notsup Actual: {"npm":"1.4.28","node":"0.10.35"}
npm ERR! System Linux 3.13.0-32-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "update" "-g"
npm ERR! cwd /home/ekrem
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code ENOTSUP
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ekrem/npm-debug.log
npm ERR! not ok code 0
When I hit (sudo) npm update -g npm, here's the result I got:
npm#2.1.3 /home/ekrem/.node/lib/node_modules/ionic/node_modules/npm
After hitting npm -v
1.4.28
I've also cleared all files under ~/.npm, cleared cache, reinstall components I needed but nothing changes. In addition;
➜ ~ which node
/usr/bin/node
➜ ~ which npm
/usr/bin/npm
➜ ~ less ~/.npmrc
prefix = ~/.node
I've checked similar issues on the net but there's nothing close to mine.
UPDATE:
I've removed nodejs; cleared files under ~/.node & ~/.npm (as #johns has suggested) installed using first method of the instructions here. Here are updated outputs:
➜ node -v
v0.10.35
➜ npm -v
1.4.28
➜ which node
/home/ekrem/local/bin/node
➜ which npm
/home/ekrem/local/bin/npm
➜ npm update -g npm
# returns nothing
➜ ~ npm config get prefix
/home/ekrem/.node
I was facing a similar issue and found this post. The way I got npm to work after several tries is to remove all the npm 'node_module' folders and delete any npm config files particularly the .npmrc file in your home directory.
Then I ran 'sudo apt-get purge nodejs'.
I went to the installer and reinstalled nodejs using the following:
'curl https://npmjs.org/install.sh | sh'
then ran:
sudo apt-get install nodejs
Finally I ran:
npm update -g npm
There were issues posted about a bug in that 'update' function, but it seemed to work for me and I got from 1.4 to 2.7.
I hope this saves someone some time.
This solution worked for me
navigate to C:\Program Files (x86)\nodejs with cmd.exe and then run the installation without -g:
npm install npm
In my case I had to do the following steps to go from npm#1.4.28 to npm#3.2.0 (currently the latest):
curl -L https://www.npmjs.org/install.sh | sudo sh
This line may trigger some errors like:
Error: EACCES, mkdir '/usr/lib/node_modules/npm'
If so, simply run:
sudo rm -rf /usr/lib/node_modules/npm (or the specified directory display in the error)
From there:
sudo npm install -g npm#3.0-latest
And now the
npm -v
successfully display a beautiful: 3.2.0
There are a lot of comments out there about "npm update -g" being broken and to not use it for now:
https://github.com/npm/npm/issues/6247
I'd trying resetting or reinstalling npm and then go from there - a fresh reinstall of npm should be relatively painless and fix things:
https://github.com/npm/npm/wiki/Troubleshooting#if-your-npm-is-broken
Similar answer to #ThinkBonobo, but all I had to do was run the update straight from npmjs.org. From a freshly provisioned instance:
$curl -sL https://deb.nodesource.com/setup | sudo bash -
$sudo apt-get install nodejs
$npm -v
1.4.28
$curl -L https://npmjs.org/install.sh | sudo sh
$npm -v
2.7.3
No other steps were requried.

Getting npm: command not found. How do I reinstall NPM when Node is already installed? Where did NPM go?

I'm starting Learn to Build Modern Web Apps with the AngularJS Tutorial and running into issues very early.
I have node installed:
/path/ang-news node -v
v0.10.26
I was using NPM earlier but was running into trouble with Yeoman. I've repeated these steps a while back but Grunt stopped working so I started fresh.
I ran:
$ sudo npm install -g generator-angular
and all the dependencies were installing until I received:
npm WARN package.json mongo#0.1.0 No repository field.
npm ERR! peerinvalid The package generator-karma does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer generator-angular#0.9.1 wants generator-karma#>=0.8.2
I then tried updating:
$ npm update -g
I should have run this as an administrator. I received tons of error messages, this seemed most pertinent:
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.1.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "update" "-g"
npm ERR! cwd /path/ang-news
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! not ok code 0
Then I tried uninstalling generator-karma and starting fresh:
$ sudo npm uninstall -g generator-karma
but received:
sudo: npm: command not found
$ npm -v
-bash: /usr/local/bin/npm: No such file or directory
My first question is: Why did NPM suddenly disappear?
[EDIT: Kudos to #try-catch-finally to pointing out the havoc that ensues when switching between normal user and sudo when issuing commands. It turns out that I messed up my user environment and NPM was no longer installed.]
My understanding is that NPM is installed when you install Node, so my second question is: How do I reinstall just NPM? I'd prefer not to have to reinstall Node from the beginning.
[EDIT: Kudos to #hawk and #try-catch-finally - it doesn't appear that installing NPM alone is an option, but there are easy ways to reinstall both.]
If you have a working node, you can re-install npm
curl -L https://npmjs.org/install.sh | sudo sh
Unfortunately npm update -g does not do what anybody expects. Fixing this is on the npm roadmap, but it's going to take a while.
You almost never need to install a package globally, unless (like generator-angular or grunt-cli) you want to use that package as a command.
Just in case you've done this with brew, I recommend this article on github. Will save you a lot of time.
https://gist.github.com/DanHerbert/9520689
Fixing npm On Mac OS X for Homebrew Users
Run the following commands to remove all existing global npm modules, uninstall node & npm, re-install node with the right defaults, install npm as its own pacakge, and configure the location for global npm modules to be installed.
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh
Node and npm should be correctly installed at this point. The final step is to add ~/.node/bin to your PATH so commands you install globally are usable. I added this line to my ~/.path script, which gets run via ~/.bash_profile. Run the following line as is.
export PATH="$HOME/.node/bin:$PATH"
I met the exactly same problem after execute command to install the npm with latest version on redhat 7.1:
npm install npm#latest -g
after some tries i found the solution:
yum reinstall npm
I hope this could help redhat/centos users.

NPM install giving error installing express

When I give command npm install express it throws following error. On ubuntu machine
gaurav#gaurav-Mini-Monster:~/TestScripts$ sudo npm install -g express
npm ERR! error installing express#3.3.3 Error: Unsupported
npm ERR! error installing express#3.3.3 at checkEngine (/usr/local/lib/node_modules/npm/lib/install.js:493:14)
npm ERR! error installing express#3.3.3 at Array.0 (/usr/local/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
npm ERR! error installing express#3.3.3 at LOOP (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:13)
npm ERR! error installing express#3.3.3 at chain (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:4)
npm ERR! error installing express#3.3.3 at installOne_ (/usr/local/lib/node_modules/npm/lib/install.js:470:3)
npm ERR! error installing express#3.3.3 at installOne (/usr/local/lib/node_modules/npm/lib/install.js:411:3)
npm ERR! error installing express#3.3.3 at /usr/local/lib/node_modules/npm/lib/install.js:347:9
npm ERR! error installing express#3.3.3 at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:54:35
npm ERR! error installing express#3.3.3 at Array.forEach (native)
npm ERR! error installing express#3.3.3 at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:54:11
npm ERR! error rolling back express#3.3.3 Error: UNKNOWN, Unknown error '/usr/local/lib/node_modules/express'
npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: connect#2.8.3
npm ERR! Required: {"node":">= 0.8.0"}
npm ERR! Actual: {"npm":"1.0.106","node":"0.5.11-pre"}
npm ERR!
npm ERR! System Linux 3.2.0-48-generic-pae
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "express"
npm ERR! cwd /home/gaurav/TestScripts
npm ERR! node -v v0.5.11-pre
npm ERR! npm -v 1.0.106
npm ERR! code ENOTSUP
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/gaurav/TestScripts/npm-debug.log
npm not ok
I also tried
sudo npm install express
npm install -g express
sudo npm install -g express
Nothing works.
Node is so easy to install manually. I like doing it this way too because it's really easy to switch versions.
This is also great because you don't need to add some external package repository to apt, and you don't have to wait for those repositories to update when node releases a new version. You can get updates as soon as they're released.
# make a `~/.nodes/ folder
mkdir -p ~/.nodes && cd ~/.nodes
# download the binaries from nodejs.org
# in this case, here's the linux version
curl -O http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-x64.tar.gz
# extract
tar -xzf node-v0.10.12-linux-x64.tar.gz
# rename folder to 0.10.12
mv node-v0.10.12-linux-x64 0.10.12
# create a `current` symlink
ln -s 0.10.12 current
# prepend ~/.nodes/bin to your path
# you'll want to save this in ~/.bashrc or ~/.zshrc or something
export PATH="~/.nodes/current/bin:$PATH"
# cleanup
rm ~/.nodes/node-v0.10.12-linux-x64.tar.gz
The best part about this is you can repeat the pattern for any other version of node, change the current symlink at any time to switch which version you're running, and you're good to go
% node --version
v0.10.12
% npm --version
1.2.32
# switch versions to (e.g.) 0.10.5
% cd ~/.nodes && rm current && ln -s 0.10.5 current
% node --version
v0.10.5
% npm --version
1.2.18
Additional pointers when writing executable scripts
Make an executable file
% touch ~/somefile && chmod +x ~/someifle && nano ~/somefile
File contents
#!/usr/bin/env node
console.log(process.version);
Run it
% ./somefile
v0.10.12
You are running a much-too-old version of node and npm. You have node v0.5 which is very out of date. Upgrade to node v0.10 and things will work.
Modern node.js versions for Ubuntu are available via this PPA from Chris Lea
To install:
sudo apt-get install python-software-properties
sudo add-apt-repository --yes ppa:chris-lea/node.js
sudo apt-get install nodejs
UPDATE
It looks like your old version of node is installed at /usr/local/bin/node. The new version from the Chris Lea PPA will be at /usr/bin/node. So to verify all is well, do:
/usr/bin/npm --version #Should be approx 1.2
/usr/bin/node --version #should be approx v0.10
/usr/bin/npm install -g express
You should uninstall the local node, or fix your PATH:
export PATH=/usr/bin:$PATH

Resources