Updating npm version after downgrading - node.js

I had installed the latest version of node.js version 10.16.3 and had the latest version of npm version 6.9.0
I am currently following a course on node.js and the instructor recommended to downgrade to npm version 5.5.1 to have the same version as him for the course so I did that.
Now version 5.5.1 is not supported in the latest release of node.js and if I try to run any npm commands including updating the version globally it throws the same error as shown below.
I have already tried the following:
Running npm i -g npm#latest which throws the same error as below. Basically any npm command throws that error
Completely uninstalling and reinstalling node.js however the version of npm is still 5.5.1 and not the latest
This is the error message that I get when running any npm command
npm WARN npm npm does not support Node.js v10.16.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.
npm WARN npm You can find the latest version at https://nodejs.org/
WARNING: You are likely using a version of node-tar or npm that is incompatible with this version of Node.js.
Please use either the version of npm that is bundled with Node.js, or a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is compatible with Node.js 9 and above.
npm[5864]: c:\ws\src\node_zlib.cc:551: Assertion `args.Length() == 7 && "init(windowBits, level, memLevel, strategy, writeResult, writeCallback," " dictionary)"' failed.
1: 00007FF7DC7ADD8A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4506
2: 00007FF7DC788886 node::MakeCallback+4534
3: 00007FF7DC78893F node::MakeCallback+4719
4: 00007FF7DC6E791D RSA_meth_get_flags+93021
5: 00007FF7DCCB5BF2 std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::_Umove+79442
6: 00007FF7DCCB707D std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::_Umove+84701
7: 00007FF7DCCB60D6 std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::_Umove+80694
8: 00007FF7DCCB5FBB std::vector<v8::internal::compiler::MoveOperands * __ptr64,v8::internal::ZoneAllocator<v8::internal::compiler::MoveOperands * __ptr64> >::_Umove+80411
9: 000001F722E5C5C1

I have run into the exact same problem when following the same course. I managed to fix it by uninstalling node as well as all npm files on the machine, and reinstalling node from scratch. Specifically, I managed to uninstall node and npm by following this answer.
How to completely remove node.js from Windows

i very strongly recommend to all developers who use node, to use nvm
we use nvm to very quickly switch which version of node we're using
after you use nvm to install your favorite version of node, you can upgrade npm easily with npm itself, like so
npm install -g npm#latest
instead of latest, you can specify an exact version number, like so
npm install -g npm#5.5.1
edit: i just re-read your post and see that you're specifically having troubles installing that old verison of npm with that specific version of node
consider just using whichever version of npm that particular version of node uses
also, poke and prod your instructor to "get with it", there is no excuse — using unsupported software, ESPECIALLY npm, is a TERRIBLE idea because of gaping security holes in older versions
this is software that downloads and auto-executes thousands of open source software packages, almost without any security measures -- you'd better be doing this in a throwaway virtualmachine if you're going to be using unpatched old versions of this software
again, you should shame your instructor about this, and educate them about the importance of staying on supported channels, and how to use nvm to make it easy as cake
cheers
👋 Chase

Related

Error npm is known not to run on Node.js v10.24.1 and how to fix it, don't update to the latest version?

I run : npm run dev
Error : npm is known not to run on Node.js v10.24.1
I have researched and know the command: npm install -g npm#latest and some other commands to fix the problem
But the problem is that my project is using nodejs 10 so it can't use the latest nodejs. So is there any way to fix the above error. Thank you
UPDATE :
I use nvm to install and manage versions of nodejs. And my OS is macOs
The problem for me was upgrading my global version of npm while on an incompatible version of Node (8.16.1).
I tried to uninstall npm globally but that also didn't work because I could not use the npm command.
To fix it, I used nvm to switch to a compatible version of Node (nvm use 14.0.0 - this can be any version of Node compatible with the npm version you have installed globally). This allowed me to run npm commands so I ran npm uninstall -g npm first of all to remove my global version of npm and then nvm uninstall 8.16.1 to remove my faulty Node version.
I was then able to reinstall Node 8.16.1 (nvm install 8.16.1), and with it came a fresh install of a compatible npm version.
I happen to work on a project that builds on node 10 as well.
More details would have been helpful to understand the problem better but I suspect it's a compatibility issue.
Try these:
Download and install the latest version of nodejs.
Open you terminal and verify you have the latest version using node -v. Verify your npm version too using npm -v.
Since you have nvm installed, run nvm install 10, then nvm use 10.
Verify your versions again. In my case, node is v10.24.1 & npm is 6.14.12.
Start your app using npm run dev. Please check you package.json to be sure you are using the right startup command.
I was having the same problem, I ran the command and it solved the problem with NPM
sudo n latest
Node: v10.19.0
NPM: 8.9.0
Reference
I performed an upgrade of npm by mistake and run into the same issue.
The only way to solve for me was to delete the two following directories:
C:\Users\<username>\AppData\Roaming\npm
C:\Users\<username>\AppData\Roaming\npm-cache
npm is known not to run on Node.js v10.24.1 comes when normally people upgrade the version of npm to latest or recent ones, but when it comes to node 10 version you can use npm version 6.4.1 or 6 series. Normally npm 6.4.1 will come with node js 10.24.1 but if you have given any npm update cmd you need to go to C:\Users\username\AppData\Roaming and delete npm and npm cache folders then delete npm folders in C:\Users\username\AppData\local then check the npm version using npm -v. After doing this install the angular version
Thanks #Oduola Olumide Sunday for the response. I have followed your way but still not solved the problem.
And I fix it by removing the latest nodejs version and using the normal node v10.24.1
enter link description here ->
I removed the latest nodejs version with this
This error happens when your npm version is not what you think it is...
For instance, you download a nodejs pkg and install. Run node -v, npm -v... npm -v provides the error that brought you here.
This means your aren't using the version the nodejs pkg installed, but some remnant somewhere- from other install attempts.
In my case, I had a Homebrew installed version of npm that I didn't realize existed.
You can find the locations, at least on mac, using the 'where' command.
where npm
Which will return path(s) of your npm locations. Find the one that doesn't belong and give it the boot.
Then your npm -v will return the expected version number output.
Now you can execute npm commands.
I had the same problem.
I was using node 12 with nvm
Then, I switched to node 16, uninstalled the version 12 with nvm uninstall 12 and then I installed it again with nvm install 12 and it is working fine
For nvm used under macOS, I solve this issue in this way
First, run nvm ls-remote to get the latest version of v10
-> v10.24.1 (Latest LTS: Dubnium)
Then install the latest version of v10 through
nvm install 10.24.1 --latest-npm
In case anyone here needs to install an npm version (7.24.2) that does support node 10, rather than upgrade node.
Here is what I did:
url=`(curl -qSsL https://registry.npmjs.org/npm/7.24.2; echo "") | sed -e 's/^.*tarball":"//' | sed -e 's/".*$//'`
curl -qSsL -o npm.tgz "$url"
bin/npm-cli.js install -gf ../npm.tgz # in case npm is not installed where "which npm" points to, you might need to add --prefix=$(which npm | sed 's/\/bin\/npm//')
The reference is the installation script of 7.24.2 https://github.com/npm/cli/blob/v7.24.2/scripts/install.sh
In my case I had put ^ in one of the package version in my package.json. Which takes latest version of that library and it was not compatible to older npm version which caused me this error.
Remove all ^ from package versions and try again.
your nodejs version should come with its own npm that it supports.so if your machine has issues finding the npm version go to cdrive C:\Users\Machine name\AppData\Roaming
delete npm and npm cache folders.
Try below command
brew install node
then
npm install
None of the tips I found here helped.
I had to reinstall nvm.

npm does not support Node.js

npm does not support Node.js v15.5.0 as well as v14.15.3
npm Version: 5.6.0
I upgraded it trough the command: npm i -g npm-upgrade
But I don't get version 6, I always get version 5.6.0
I also tried different Node.js versions according to 426750.
I tried following Node.js versions: v15, v14, v12, v9. It doesn't matter which Node.js version I install, i always get the samme error.
I also removed Node.js and updated it as recommended in 47226238, 63196042.
I have no Idea how I can fix this problem. Do you have any suggestion?
The correct command to update npm is npm install -g npm. At the time of this writing, that will install npm#6.14.10. (If it doesn't, try npm install -g npm#6.)
Installing npm-upgrade instead will install a CLI that updates package.json in projects. It will not update npm itself.
EDIT: The version compatibility stuff is just a warning. Based on the comment below, the ERR! cb.apply is not a function stuff is the real problem. You may have multiple versions of npm or node installed in different paths and your PATH or alias configuration is causing incompatible versions to run with each other.
EDIT (continued): If you are using nvm as a version manager, you can downgrade to a previous version, remove/reinstall the current version of Node.js, and you will have a compatible version of npm. If you are not using nvm, installing it (assuming you are on a development machine and not experiencing these issues in production) and using node and npm provided by it should also solve the issue.
EDIT PART 3: I just noticed you are running Node.js 15.5.0. That ships with npm#7 so do npm install -g npm#7. If that doesn't work, find your executable paths for node and npm. (On UNIX-like operating systems: command -v node and command -v npm.) If they are not in the same directories, that sounds like a problem and you should investigate. It will probably be easiest/best to use the npm that is in the same directory as node. You can try that out by using the full path. If that works, figure out what's wrong with your PATH or your aliases that you're using a different npm and fix that.

Proper method to get the latest npm on macOS?

When I did npm -v it showed version 7.something.
I just wanted to make sure I have the latest available, so I did npm install -g npm.
It seemed to work OK (it did go through a install/upgrade process) but when I now do npm -v it says 6.14.9.
What is the 'correct' or proper way to get the latest npm on macOS? And I mean in a global way (for my entire coding environment) so that any NodeJS project in any directory will universally use the latest npm.
FYI I'm using macOS Catalina 10.15.6.
npm 7 ships with Node.js 15.x but is not yet the default latest within the npm registry. Confusing! If you want the latest 7.x version of npm, you need to specify that you want version 7: npm install -g npm#7. Otherwise, it will give you the latest 6.x release.
I recommend using nvm to manage your node versions. It allows switching between projects with different versions without running into version issues.
With it, you can use nvm install node to install the latest one, or nvm ls-remote to list available versions for install.

nodejs 4.2.6 not getting updated to latest version

I installed Node and npm as they are required to install angular cli.
Now, if I type this command:
npm install -g angular-cli
I get this message in terminal:
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 4.7.0 to use this version of npm. You can find the latest release of Node.js at https://nodejs.org/
I also followed this link, but still the issue is not resolved.
I tried removing node, npm and then reinstalling, updating node according to all the ways I found on internet, but still the version(4.2.6) is same.
I don't understand what I am doing wrong as I am new to Linux.
Surprisingly, npm is quite complicated in Linux, until you discover Node Version Manager which allows you to easily install new versions and swap between them.
After installing nvm, you can install any node version with nvm install <VERSION_NUMBER> and you can set it as default with nvm alias default <VERSION_NUMBER>
You can swap between versions using nvm use <VERSION_NUMBER>

Install Node in ubuntu

I want to install node to run Angular2 program, but while installing I am getting this error:
npm WARN npm npm does not support Node.js v0.10.25
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 You can find the latest version at https://nodejs.org/
npm WARN using --force I sure hope you know what you are doing.
/usr/local/lib/node_modules/npm/lib/cache.js:3
const BB = require('bluebird')
^^^^^
npm ERR! Use of const in strict mode.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/swapnily/.npm/_logs/2017-07-04T10_51_42_147Z-debug.log
I've already tried this solution:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
but even for first command "sudo npm cache clean -f" I am getting same issue. Please let me know if anyone aware about same.
I, personally, am a huge fan of nvm.
It makes node installation and versions manipulations so easy.
All install instructions can be found here.
I'll just give an example command of installing new nodejs version and start using it, so you understand how clear and easy it is:
nvm install 8.0
nvm use 8.0
I suggest you download the Node archive from official site(https://nodejs.org/en/)
After that, you need the create a soft link to the bin file you just download from the site, the command line words may like this:
ln -s /opt/node-v6.10.2-linux-x64/bin/node /usr/bin/node
Same for npm
$ sudo apt update
$ sudo apt install node.js
To check the version of Node:
$node -v
Installing Using a PPA; to get recent version of Node.js you can add the PPA (personal package archive) maintained by NodeSource. This will have more up-to-date version of Node.js than the official ubuntu repositories, and will allow you to choose between Node.js c6.x (which is supported until April of 2019), Node.js v8.x (the current LTS version, supported until December of 2019), and Node.js v10.x (the latest version, supported until April of 2021).
First, install the PPa in order to get access to its contents. From your home directory, use curl to retrieve the installation scripts for your preferre version, making sure to replace 8.X with your preferred version string (if different)
Check this link to continue: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04?

Resources