Receive "must point to an installed version of node" when trying to upgrade - node.js

When trying to upgrade my Node version using either
nvm install v10.15.0 --reinstall-packages-from=8.9.4
or
nvm install lts/* --reinstall-packages-from=node
I receive the following error:
If --reinstall-packages-from is provided, it must point to an installed version of node.
I also tried changing =node to a path that points to where I have installed node, e.g., /usr/local/bin/node.
I have also tried not using the NVM method, and using the instructions provided here, but I receive the following:
WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/n-3eb27508/.github' /usr/local/lib/node_modules/.staging
WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/n-3eb27508/bin'
npm ERR! path /usr/local/lib/node_modules/n/bin/n
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/n/bin/n'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Any ideas?

In my case, it was because I had installed Node directly from the installer at the Node.js website, and the first time I tried to update it with npm, I got a permissions error, and was pointed to a solution to use nvm. So in my case, I think the error was because nvm was unaware of my previous installation of Node. Ended up just completely deleting node, npm and related files from my Mac (as per How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)) and just doing nvm install node

Resolved this by simply downloading a new version of the OSX installer from the Node JS website and overwriting the previous version!

Related

How can I install nodejs manually in Linux from terminal

I have downloaded Nodejs in my Linux VM from nodejs.org, I want to install it from terminal. VM have already installed node v0.12.18 manually by someone else, I don't know how to do that. As I am installing nodejs offline, I should not depend on that whether or not npm installed.
I have tried [location]~ npm install node-v15.6.0-linux-x64.tar.gz
Getting below error
[host#machinename ~]$ sudo npm install node-v15.6.0-linux-x64.tar.gz
npm WARN excluding symbolic link bin/npm -> ../lib/node_modules/npm/bin/npm-cli. js
npm WARN excluding symbolic link bin/npx -> ../lib/node_modules/npm/bin/npx-cli. js
npm ERR! addLocal Could not install /home/usermachinename/node-v15.6.0-linux-x64.tar.g z
npm ERR! Linux 3.10.0-1062.9.1.el7.x86_64
npm ERR! argv "/usr/local/lib/nodejs/node-v0.12.18-linux-x64/bin/node" "/usr/loc al/lib/nodejs/node-v0.12.18-linux-x64/bin/npm" "install" "node-v15.6.0-linux-x64 .tar.gz"
npm ERR! node v0.12.18
npm ERR! npm v2.15.11
npm ERR! path /tmp/npm-1637-a9cb4311/unpack-5a7f411732fb/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! enoent ENOENT, open '/tmp/npm-1637-a9cb4311/unpack-5a7f411732fb/package .json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /home/usermachinename/npm-debug.log
How can I fix this?
You can't install the file using npm install, but since you already have the compressed file for node, my answer will hopefully help you achieve your goal.
First of all you will have to extract the tar.gz file you have node-v15.6.0-linux-x64.tar.gz, to do so just navigate to the folder where the file placed in then do the below command.
tar xf node-v15.6.0-linux-x64.tar.gz
Since you're using Linux the below command will add the new extracted node to your path.
nano ~/.profile
Add the following lines to the end:
# NodeJS
export NODEJS_HOME=/{path_to_the_extracted_folder}/node-v15.6.0-linux-x64/bin
export PATH=$NODEJS_HOME:$PATH
Please make sure you change {path_to_the_extracted_folder} to the path where you extracted the compressed file in the previous step.
Finally you can click CTRL+C to exit nano, type y then click enter.
To refresh the profile file enter the below code
. ~/.profile
Finally
To make sure everything is working fine check the nodeJs version by entering this command node -v it has to print v15.6.0.
You will not have to worry about the previously installed node version since above steps will change the nodeJs path.

npm install errors; npm WARN tar EPERM: operation not permitted, futime

Noob here, I am trying to use bash terminal to install npm modules and use as a Remote-WSL terminal.
Some background info, I am using VSCode as my code editor. I am trying to make a javaScript app using node.js. I set up Ubuntu terminal on Windows 10.
After updating npm to the latest version I started getting these errors when trying to install express, using npm install express --save
npm WARN tar EPERM: operation not permitted, futime
npm WARN tar EPERM: operation not permitted, futime
npm WARN tar EPERM: operation not permitted, futime
// etc, etc, etc 500x...
npm WARN bashdemo#1.0.0 No description
npm WARN bashdemo#1.0.0 No repository field.
npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path /mnt/d/Program Files/Workspace/bashDemo/node_modules/bytes
npm ERR! dest /mnt/d/Program Files/Workspace/bashDemo/node_modules/.bytes.DELETE
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, rename '/mnt/d/Program Files/Workspace/bashDemo/node_modules/bytes' -> '/mnt/d/Program Files/Workspace/bashDemo/node_modules/.bytes.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/aaron/.npm/_logs/2019-11-14T21_41_32_512Z-debug.log
This issue persists regardless of the module I am trying to install....
Even after reverting to the original version of npm that was working, 6.12.1, these errors persist.
If I run npm install I get
npm WARN bashdemo#1.0.0 No description
npm WARN bashdemo#1.0.0 No repository field.
up to date in 0.636s
found 0 vulnerabilities
I tried clearing my caches, resetting, uninstalling, turning the linux subsystem off/on, restarting my computer each time, and reinstalling Ubuntu then going through the set up process, updating, upgrading, installing nvm using curl script on the github page about 3x now.
I tried, unmounting and remounting my /mnt/c/ following guides for previously reported issues that seemed similar. Which only served to make things worse, (prompting a reset and reinstall of Ubuntu terminal).
Another way you can get this error is that the windows C: drive is mounted with root ownership rather than user ownership.
See: chmod chown wsl improvements
The short answer is that you need to remount the C: drive with new permissions
sudo mount -t drvfs C: /mnt/c -o metadata,uid=1000,gid=1000,umask=22,fmask=111
A friend of mine helped me resolve this issue. Was a small and easy to overlook mistake on my part >.>
In short, It was resolved by just reinstalling node.js on windows... :/
During my update process, I uninstalled node.js to perform a clean installation. If I ran node -v in the bash terminal, I would see the version number and know that it was installed within the linux subsystem.
However, if I were to check in Powershell for node.js, I would find that it was not installed as I did not find a version number returned. I must have missed reinstalling Node back onto my machine. I Likely installed in a different place and in my nubbish confusion of uninstalling and reinstalling things, I neglected to put it back where I had it installed originally.
In conclusion, if you are using the linux subsystem as your command line terminal when working with node.js, make sure Node was properly installed on Windows.
P.S. I was not having the drive mounting issue others were having when getting this same type of error, so my issue resolved by reinstalling Node in the place I previously had it beforehand.
For me turning the antivirus off worked. It was not allowing edits to the folder.

npm WARN: npm does not support Node.js v12.4.0

I've been getting the following warnings lately whenever I run any npm script:
npm WARN npm npm does not support Node.js v12.4.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 6, 8, 9, 10, 11.
npm WARN npm You can find the latest version at https://nodejs.org/
It says that I should upgrade to a newer version, but v12.4 is the newest version. Even though the scripts run fine, I think there's no guarantee and something might break at any moment.
I've also tried updating npm in case there's a newer version using npm install npm -g but got the error:
npm ERR! path /usr/local/Cellar/node/12.4.0/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'] {
npm ERR! stack: 'Error: EACCES: permission denied, access ' +
npm ERR! "'/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
Then I've seen that Homebrew version of npm can't be updated using npm itself, so I tried updating through Homebrew using brew upgrade npm but got this error:
Error: npm 12.4.0 already installed
For some reason Brew mixes up nodes and npms versions.
What am I doing wrong and how can I get rid of this warning?
What worked for me:
if you try running this command "npm cache clean -f" and it doesn't work,
on your windows machine(mine is windows 10)
access the "npm" and "npm-cache" folders in this location "~\AppData\Roaming\"
delete these two folders "npm" and "npm-cache".
go to your windows search bar and search for Node, right click to open file location, run the uninstaller to uninstall NodeJs.
then visit nodejs.org and download and install node again, if you've already downloaded it, visit the folder where you downloaded it to reinstall it.
after installation, check your version of npm by typing "npm -v" on your command terminal to see the new updated version of npm installed on your machine.
now you're all set, Happy coding.
Seems like you messed up with permissions in /usr/local.
Here is how to fix that:
Fix /usr/local permissions:
sudo chown -R `id -un`:`id -gn` /usr/local
Clean npm cache and uninstall it:
npm cache clean -f
npm -g uninstall npm
Reinstall node (with npm)
brew reinstall node
Upgrade npm:
npm -g i npm
That should bring npm#6.9.2.
You should avoid using sudo while installing software with brew or npm, that could cause issues like this.
If you have nvm you may have an issue in which your node version installed at a certain version didn't match.
For example, I accidentally used: npm i -g node --force resulting in my nvm v12.21.0 to point to v16.5.0 (the latest version of node at that time directly downloadable).
To solve: I ran:
Just for good measure brew uninstall nvm
brew install nvm.
nvm uninstall 12.21
nvm install 12.21
Just for good measure I ran npm i -g npm resulting in the latest version of npm installed on that virtual node.
After installing within some repo (using npm i) you may also want to check your: ~/.npmrc.
email=myemail#company.com
registry=https://artifactory.company.com/npm/npm/
always-auth=true
user-agent=npm/6.14.11 node/v12.21.0 darwin x64
_authToken=siofjwoirgiowrgnioaenrvoianeoiio32noi23nio23nio23nio
It should look something like this: (or you might not have any of that.
Had the same issue with Debian 10 (buster) when I tried installing the npm and node.js. They were incompatible and wouldn't update. This was what I found works for me.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
The nodejs package was installed at a different path and I manually deleted the old package (in /usr/bin/) and added a symlink to point to the new one (in /usr/local/bin).
sudo rm /usr/bin/node
sudo ln -s /usr/local/node /usr/bin/node
This is the initial printouts from running the commands. The npm version updates from 5.8.0 to 8.1.2. But the nodejs version stayed at 10.24.0 even after reboot with hash -r.
None of the answers here worked. I had to delete the npm and npm-cache folders, then reinstall npm. Details here: npm does not support Node.js v12.18.3
After step 4 posted by Styx, and if node claims installation fo a newer version but npm -v keeps showing outdated version
Code for Mac and node installed with brew:
cd /usr/local/bin/
mv npm npm-backup
mv npx npx-backup
ln -s /usr/local/Cellar/node/14.2.0/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
ln -s /usr/local/Cellar/node/14.2.0/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx
npm -version
6.14.5
I hit this issue and the steps above didn't work for me. I think it can happen if you try to upgrade Node or NPM without updating the other also. At least I think that's what happened to me.
I was trying to create a new Angular project and I had a very old version on my machine. I got an error to upgrade Node, so I bumped it to the latest version. After that I got the error running any npm command.
I resolved it simply by going to:
https://nodejs.org/en/download/
Getting the latest version and installing that in a pkg file (mac). After install was complete I was able to run everything. I'm guessing it worked because the versions of each mismatched, so one wouldn't run without the other being downgraded.
I also tried the brew option but I was getting other issues. My corporate machine sometimes blocks installations in that route, so it might work for others.
For Windows, this was driving me crazy, and all of the above solutions were not working, I would still get the old version of node showing for node -v.
For me simply killing the terminal window and starting it again resolved the issue. No amount of cache clearing worked until this. I know it sounds dumb, but that's what resolved this for me in the end. Hope this helps someone else not lose hours farting around with this.
I've have this issue in npm -v package,so you have to easy step in follow of solve this problem.
npm use stable
nvm use stable
nvm cache clear
nvm install stable --default
you can closed the terminal then check the `npm --version
Looks like a permission issue. Try with sudo

npm (version 5.5.1) install errors

I have installed node version 9.2.0 and npm version 5.5.1
On the command line, I want to install packages:
$ npm install express --save
npm WARN bookstore#1.0.0 No repository field.
npm ERR! path C:\Users\ad\Projects\bookstore\node_modules\bytes
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename
'C:\Users\ad\Projects\bookstore\node_modules\bytes' ->
'C:\Users\ad\Projects\bookstore\node_modules\.bytes.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ad\AppData\Roaming\npm-cache\_logs\2018-03-
14T06_36_04_014Z-debug.log
What does this mean? Maybe I should uninstall node version 9 and revert to the LTS-version 8? And how to do that in Windows?
Please, I need help; thank you in advance!
EDIT: Could it be caused by a slow internet connection; npm not being able to find a file.?
EDIT 2: I was able to uninstall node version 9.2.0, then installed version 8.10.0 :-( Still the same error messages!
First Use Below Command
touch .npmignore
Then Install Express
npm install express --save
I found a solution, but this is really stupid! Let me explain: I have been using Visual Studio Code for months now, and it's inbuilt command line (bash). Never had any issues with it!
But now; there must be something wrong with VS Code, giving these errors.
I tried an alternative: Git-Bash command window and separately Sublime Text 3. And it works! I could install all dependencies that were needed, without any errors or warnings!
Can someone explain this strange behavior I had using VS Code?

Why does NVM install think I am using the wrong version of Node?

While trying to install the less node module globally via the Node Package Manager, I ran into an interesting problem that I am having trouble solving. Basically, I am getting an error that claims the node module, less, is incompatible with my version of node. It says I am using node v0.6.12 and that it requires at least v0.8.0 to work.
First I made sure that I was using one of the latest versions of Node:
nvm use v0.10.11
Now using node v0.10.11
node -v
v0.10.11
Then I tried to install the less module globally:
sudo npm install -g less
And got this error message:
npm ERR! error installing less#1.4.0
npm ERR! error rolling back less#1.4.0 Error: UNKNOWN, unknown error '/usr/local/lib/node_modules/less'
npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: request#2.21.0
npm ERR! Required: ["node >= 0.8.0"]
npm ERR! Actual: {"npm":"1.1.4","node":"0.6.12"}
npm ERR!
npm ERR! System Linux 3.2.0-45-generic
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "less"
npm ERR! cwd /home/derek
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! code ENOTSUP
npm ERR! message Unsupported
npm ERR! errno {}
npm not ok
Here you can see that the node package manager is trying to install less using (or thinks it is using) node v0.6.12. It seems as though some others have run into this problem, but his problem turned out to be that he had previously installed node via apt-get, and was resolved by him using the Node Version Manager. I initially installed Node via NVM, however.the Any help that you guys could offer would be greatly appreciated.
Note: It is worth mentioning that it will successfully install using npm install -g less, without sudo permissions. However, as soon as another terminal is opened, the less node module is removed from /usr/local/lib/node_modules, rendering it useless.
Have you tired completely removing the old version, v0.6.12 with something like
sudo apt-get purge node.
I'm not a great with linux, but it seems sudo still has the old version of node in its path and calling npm under sudo is finding it and trying to use it.
The Node.js installed with Linux is probably installed in /usr/sbin/ (at least it was for me on Ubuntu 13.04). That's the old version. Since you have nvm installed and having that manage your Node.js versions, you'll want to point to ~/.nvm/v0.10.11/bin/node.
You already got a nodejs copy on your system.
The solution is to re-install or overwrite your node using /usr/local for your prefix
git clone https://github.com/joyent/node
cd node
./configure --prefix=/usr/local
make
sudo make install
Here is a similar problem:
how to delete node on linux mint 13?

Resources