72

Can see it's been asked a dozen times but none of the solutions I've found have worked for me so far.

I've installed the latest version of Node.js (12.18.3) on my Windows 10 PC and I'm trying to install a package using npm. When I input npm -v it comes back with 5.6.0, which to me looks out of date - but when I try and install a package or update npm, I get the following error every time:

npm WARN npm npm does not support Node.js v12.18.3
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! cb.apply is not a function

npm ERR! A complete log of this run can be found in:

I've tried uninstalling Node.js completely, deleting all node_modules folders and restarting my computer after a fresh install, but it's the same thing each time. I've also tried using npm install -g npm and npm install npm@latest -g but again, I get the same error.

Any solutions here?

Amy
  • 1,088
  • 2
  • 11
  • 24
  • 1
    Does this answer your question? [npm WARN npm npm does not support Node.js v9.1.0](https://stackoverflow.com/questions/47226238/npm-warn-npm-npm-does-not-support-node-js-v9-1-0) – Rvy Pandey Jul 31 '20 at 16:55
  • I've tried this solution, it does not. Unless I'm not uninstalling npm correctly – Amy Jul 31 '20 at 16:57
  • As other questions say, remove npm and install it again. If you remove and install it and you still have the old npm version, is that you don't uninstalled it properly (you have it installed somewhere else). Note how you are trying to use `npm` to install `npm`, but if npm don't works you cannot run those commands. You need to do that other way, depending on your OS. – Jorge Fuentes González Jul 31 '20 at 16:58
  • How do you remove npm completely? I'm new to Node.js – Amy Jul 31 '20 at 16:59
  • How did you install npm? – Take-Some-Bytes Jul 31 '20 at 17:03
  • Installed it with Node on the custom set up 'npm package manager' – Amy Jul 31 '20 at 17:19

13 Answers13

167

I found the work-around !

First you need to open your cmd line, and use " npm install -g npm@latest " you'll get the error like this

C:\Users\KimeruLenovo>npm install -g npm@latest
npm WARN npm npm does not support Node.js v14.7.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! cb.apply is not a function npm ERR! A complete log of this
run can be found in: npm ERR! 
C:\Users\KimeruLenovo\AppData\Roaming\npm-cache\_logs\2020-08 10T09_36_56_388Z-debug.log

Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming

Delete the NPM and NPM-Cache folder, but DO NOT reinstall node . once deleted go back to your comand line and re-use the command " npm install -g npm@latest "

This should do the trick :)

Riaan van Zyl
  • 538
  • 8
  • 17
Laurent Luypaert
  • 1,812
  • 1
  • 6
  • 9
  • 9
    Worked like a charm! Thank you. – mpatel Aug 21 '20 at 22:39
  • 4
    Powershell: `remove-item "$($env:appdata)\npm" -Recurse; remove-item "$($env:appdata)\npm-cache" -Recurse` – fiat Sep 15 '20 at 23:17
  • Note : When you run the command again, it generates some errors. But ignore it and try npm install command again and it should work. – Jake Nov 29 '20 at 06:35
  • wow, that's saved me, thanks. I guess it's enough to delete npm in that folder (C:\Users\USER\AppData\Roaming\npm\node_modules\npm) – Shrike Dec 28 '20 at 21:54
  • I tried this and am getting this message in console: [..................] / rollbackFailedOptional: verb npm-session 5c84eea6445ede3a ideas? – JasonBK Jul 13 '21 at 15:39
  • @JasonBK I did some research, since I have no idea about your workspace or environment, I assume this is due Firewall protections: Article I've found about this : https://stackoverflow.com/questions/46011546/npm-install-error-rollbackfailedoptional There is an solution in that article that worked for quite some people. – Laurent Luypaert Jul 15 '21 at 09:32
6

I also had the same issue, Windows 10 with npm v6.4.1 and trying to upgrade node from v9 to v12.18.3.

The problem seemed to be that whenever I tried to install the latest version of node, npm wasn't upgraded and npm v6.4.1 only supported node up until v11 (even though the download page says "Latest LTS Version: 12.18.3 (includes npm 6.14.6)": https://nodejs.org/en/download/).

This Github issue led me to the solution, which was to uninstall node (Settings -> Add or remove programs), then navigate to C:\Users\{User}\AppData\Roaming and delete the npm and npm-chache folder and finally install node again (using the installer).

bendikiv
  • 83
  • 1
  • 8
  • 1
    This worked for me on Win 10, installing the node LTS at 14.5.1. Surprising this is an issue as it would be easy for them to validate for on install. Thanks for posting. – Kzrbill Dec 02 '20 at 12:06
2

I had the same problem. Delete node and npm cache in AppData folder inside C: drive and install recommended version on another drive.

Masood
  • 1,545
  • 1
  • 19
  • 30
2

The problem on my end was arising because I was using NVM yet I had already previously installed NPM independently. All I did to solve the issue was delete the npm and npm-cache folder located here:

C:\Users\your-username\AppData\Roaming. No need of doing a fresh npm install (just leave that to NVM)

David Njuguna
  • 803
  • 7
  • 8
1

Go to the path where you can find the debug log (this file is found in your npm-cache folder) C:\Users\yourname\AppData\Roaming Delete the NPM and NPM-Cache folder, but DO NOT reinstall node. Once deleted go back to your command line and re-use the command " npm install -g npm@latest "

0

I had same issue.

I tried to install node with choco install -y nodejs.install. then, npm i works fine. (before that, nodist was uninstalled)

I used nodist to install node. it may be the cause I think.

tkt
  • 1
  • 4
0

I have the same problem even after reinstalling Visual Studio. Cleared caching, and the weird thing, the Node.Js which is installed is the lastest (12.18.3)

So far i've found the node modules of the npm package, in the troubleshooting file they were accuring this solution

"

You can check your npm version by running npm -v.

Steps to Fix

  • Upgrading on *nix (OSX, Linux, etc.)

(You may need to prefix these commands with sudo, especially on Linux, or OS X if you installed Node using its default installer.) You can upgrade to the latest version of npm using: npm install -g npm@latest Or upgrade to the most recent LTS release: npm install -g npm@lts

  • Upgrading on Windows

We have a detailed guide for upgrading on windows on our wiki.

Proxy and Networking Issues

npm might not be able to connect to the registry for various reasons. Perhaps your machine is behind a firewall that needs to be opened, or you require a corporate proxy to access the npm registry. This issue can manifest in a wide number of different ways. Usually, strange network errors are an instance of this specific problem.

Sometimes, users may have install failures due to Git/Github access issues. Git/GitHub access is separate from npm registry access. For users in some locations (India in particular), problems installing packages may be due to connectivity problems reaching GitHub and not the npm registry.

If you believe your network is configured and working correctly, and you're still having problems installing, please let the registry team know you're having trouble.

Steps to Fix

  1. Make sure you have a working internet connection. Can you reach https://registry.npmjs.org? Can you reach other sites? If other sites are unreachable, this is not a problem with npm.

  2. Check http://status.npmjs.org/ for any potential current service outages.

  3. If your company has a process for domain whitelisting for developers, make sure https://registry.npmjs.org is a whitelisted domain.

  4. If you're in China, consider using https://npm.taobao.org/ as a registry, which sits behind the Firewall.

  5. On Windows, npm does not access proxies configured at the system level, so you need to configure them manually in order for npm to access them. Make sure you have added the appropriate proxy configuration to .npmrc.

  6. If you already have a proxy configured, it might be configured incorrectly or use the wrong credentials. Verify your credentials, test the specific credentials with a separate application.

  7. The proxy itself, on the server, might also have a configuration error. In this case, you'll need to work with your system administrator to verify that the proxy, and HTTPS, are configured correctly. You may test it by running regular HTTPS requests.

"

I'll try to work on it and keep you informed if i'm able to solve this problem

F.H.
  • 1,456
  • 1
  • 20
  • 34
Laurent Luypaert
  • 1,812
  • 1
  • 6
  • 9
  • Microsoft Windows [Version 10.0.19041.388] (c) 2020 Microsoft Corporation. All rights reserved. C:\Users\KimeruLenovo>node -v v12.18.3 C:\Users\KimeruLenovo>npm -v 5.6.0 This is after the suggest removal of the NPM -Cache folder ( even did a hard cache clean of all files) – Laurent Luypaert Aug 10 '20 at 09:13
0

Go to the path where you can find the debug log( this file is found in your npm-cache folder) C:\Users\KimeruLenovo\AppData\Roaming

Delete the NPM and NPM-Cache folder, but DO NOT reinstall node . once deleted go back to your comand line and re-use the command " npm install -g npm@latest "

This should do the trick :)

As mentioned earlier, is that I deleted these folders before installing the new version and also worked.

0

Start by uninstalling the node js by running npm uninstall -g npm, you will fall back to the previous version of Node.js

Greko2015 GuFn
  • 512
  • 6
  • 13
0

Just install what is required from the official site of Node.js https://nodejs.org/en/ No SO version or command lines required

ilidiocn
  • 323
  • 2
  • 5
0

If none of these solutions work which happened to me just go to https://nodejs.org/en/ and download the recommended version manually super fast!

bigchill
  • 23
  • 3
0

Use n.

I am so glad discovered this package.

if npm installed;

npm install -g n

n lts

for other ways or more details;

https://www.npmjs.com/package/n

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
i-sk
  • 1
  • 1
0

My specific case required that I use node 12.14 and I was getting this error.I tried installing the npm version but still was getting this issue

I was using NVM, so I uninstalled all other versions of node using nvm uninstall 18 And like this all other versions

Before uninstalling the last version, I was getting some error so I ran nvm deactivate After which I uninstalled the last remaining node version too

I uninstalled the npm after that, and installed just the node version I needed using NVM

nvm install 12.14

and it installed the required npm too, with it my problem was solved. Hope this would be of use to someone

Prajval Singh
  • 501
  • 3
  • 9