0

I have node version 4.2.6 installed in my machine. I have successfully installed npm as well but when I use npm -v it gives the following 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/
Zanna
  • 69,223
  • 56
  • 216
  • 327
Ninja
  • 119
  • 1
  • 3
  • Change the version then. – George Udosen Sep 21 '17 at 02:10
  • Maybe downgrade your Node.js. – Cynplytholowazy Sep 21 '17 at 02:19
  • How to install specific version of ubuntu? – Ninja Sep 21 '17 at 03:07
  • try this solution [https://stackoverflow.com/questions/46360567/error-npm-is-known-not-to-run-on-node-js-v4-2-6](https://stackoverflow.com/questions/46360567/error-npm-is-known-not-to-run-on-node-js-v4-2-6) perhaps this would work for you – Sankalp Gupta Sep 27 '17 at 10:18
  • 1
    My answer to the linked duplicate question installs the latest version of Node.js which has npm bundled with it. So npm works like a charm with Node.js because it has to, and npm can also be updated if necessary and it still works after it is updated. – karel Apr 16 '18 at 11:33

1 Answers1

0

First, completely uninstall nodejs and npm.

sudo apt remove nodejs npm

afterwards type npm -v or nodejs -v, and if it returns something like didn't find in folder /usr/bin/nodejs

You will need to delete the old files of npm and nodejs. For example you could try

sudo apt remove --purge nodejs npm

After deleting try again npm -v or nodejs -v

If it returns is not installed, to install type 'sudo apt-get install nodejs', then you can install nodejs and npm. This worked for me on Ubuntu 16.04

Zanna
  • 69,223
  • 56
  • 216
  • 327