Error: npm is known not to run on Node.js V4.2.6

2019-02-05 11:26发布

问题:

how can I solve the following error? I use Ubuntu 16. When I run any npm command such as "npm run dev" I get this error:

ERROR: npm is known not to run on Node.js v4.2.6 Node.js 4 is supported but the specific version you're running has a bug known to break npm. Please update to at least ${rel.min} to use this version of npm. You can find the latest release of Node.js at https://nodejs.org/

回答1:

First, Uninstall completely nodejs and npm.

sudo apt remove nodejs npm

Then, reinstall it over the link below:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

Refer: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions



回答2:

You can try downgrading the node version to switch from the bugged version using the following, upgrading also works if your app supports latest versions.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash

nvm install 4.2.5

nvm use 4.2.5

//check with 
node -v

//To uninstall a node version 
nvm uninstall 4.2.6


回答3:

I download latest install package from https://nodejs.org/en/ and reinstall it. Solve it!



回答4:

I just had this issue on Ubuntu 16. Use n to update to the latest version

sudo n latest

That should settle it.



回答5:

You can also use NVM - I did this to solve the same problem.

first type

nvm ls-remote to view the latest versions available,

then

nvm install [version] (I used v8.7.0)

everything should be fine after that.



回答6:

I had a similar problem but my project is part of a bigger system so neither switching to nvm instead of npm nor upgrading my version of Node.js were options.

However, moving npm backwards to a previous version was an option. I found 4.6.1 worked without complaint.

sudo npm install -g npm@4.6.1

This version of npm did not complain.



回答7:

I had the same issue with Ubuntu 16.04 and fixed it by using following commands step by step.

Firstly removed nodejs

$ sudo apt remove nodejs npm

Installed nvm using

$ curl -o- 
https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

$ nvm install 8.0
$ nvm use 8.0

After this run

$ node -v
v8.0.0


标签: node.js npm