Node versions do not match: node vs. sudo node -v ... WSL2 Ubuntu 22.04.1 - node.js

As you can see in the image below, I see two different versions of node depending on which command I run.
I need the newer version, but npm sees the old version.
Many times I've removed, purged, reinstalled, etc.
I tried installing nvm as root and setting the node version there, but that didn't help either.
If I use apt install nodejs instead of nvm, it tells me that I already have the newest version, which it believes is 12.22.9.
How do I get npm to recognize the newer version (18.12.1) of node that I installed via nvm?

It is because you have a different version of the Node.js which is installed for the root and that particular user.
First, you need to uninstall Node.js:
sudo apt-get remove nodejs
or
sudo npm rm npm -g
If you have any problem with the above commands, then after running which node command, go to that directory, and run the following commands:
rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1
Do the same thing for the current user if needed.
The default Ubuntu/Debian package manager does not have the latest Node.js, and that's why whenever you try to install Node.js with apt install nodejs it says you have the latest version.
According to the official Node.js documentation, for installing the latest version, you should follow these steps:
Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
P.S: No need to run npm or node with sudo. Therefore, I highly recommend you to not use every command with sudo.

Related

How do I find the old version of node js?

I'm trying to install "n", the nom helper on Amazon Linux. I'm having difficulty. It seems I have an old version of the node somewhere but I can't figure out where. When I run
npm install -g n
I get the below error ...
[myuser#mymachine ~]$ sudo /usr/local/bin/npm install -g n
ERROR: npm is known not to run on Node.js v0.10.48
You'll need to upgrade to a newer version in order to use this
version of npm. Supported versions are 4, 6, 7, 8. You can find the
latest version at https://nodejs.org/
[myuser#mymachine ~]$ npm -v
5.4.2
╭─────────────────────────────────────╮
│ │
│ Update available 5.4.2 → 5.5.1 │
│ Run npm i -g npm to update │
│ │
╰─────────────────────────────────────╯
But notice that when I run
[myuser#mymachine ~]$ node -v
v8.8.1
it tells me I have v8.8.1 installed, which is what I intended. How do I purge the old, unwanted version of the node so I can install my helper?
Easiest solution would be to try the following to cleanup your node issues and reinstall a clean version.
First remove everything related to node
sudo apt-get purge --auto-remove nodejs npm
UPDATE For yum:
yum clean all
yum -y remove nodejs
Remove these leftover files and folders as well
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules
Then install node back with nvm,
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
//To uninstall a node version
//nvm uninstall <current version>
nvm install 8.8.1
nvm use 8.8.1
//check with
node -v
npm -v
//**UPDATE**: Install your package
npm install -g n
And all should work.
UPDATE : Install Without NVM
yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_8.x | sudo -E bash -
yum install nodejs
node -v
//Install your package
npm install -g n
check the releases notes of node https://nodejs.org/en/download/releases/ you can download older version from this site
An alternative to installing Node.js through apt is to use a specially designed tool called nvm, which stands for "Node.js version manager".
Using nvm, you can install multiple, self-contained versions of Node.js which will allow you to control your environment easier. It will give you on-demand access to the newest versions of Node.js, but will also allow you to target previous releases that your app may depend on.
To start off, we'll need to get the software packages from our Ubuntu repositories that will allow us to build source packages. The nvm script will leverage these tools to build the necessary components:
sudo apt-get update
sudo apt-get install build-essential libssl-dev
Once the prerequisite packages are installed, you can pull down the nvm installation script from the project's GitHub page. The version number may be different, but in general, you can download it with curl:
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh -o install_nvm.sh
And inspect the installation script with nano:
nano install_nvm.sh
Run the script with bash:
bash install_nvm.sh
It will install the software into a subdirectory of your home directory at ~/.nvm. It will also add the necessary lines to your ~/.profile file to use the file.
To gain access to the nvm functionality, you'll need to log out and log back in again, or you can source the ~/.profile file so that your current session knows about the changes:
source ~/.profile
Now that you have nvm installed, you can install isolated Node.js versions.
To find out the versions of Node.js that are available for installation, you can type:
nvm ls-remote
Output
...
v5.8.0
v5.9.0
v5.9.1
v5.10.0
v5.10.1
v5.11.0
v6.0.0
As you can see, the newest version at the time of this writing is v6.0.0. You can install that by typing:
nvm install 6.0.0
Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:
nvm use 6.0.0
When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:
node -v
Output
v6.0.0
If you have multiple Node.js versions, you can see what is installed by typing:
nvm ls
If you wish to default one of the versions, you can type:
nvm alias default 6.0.0
This version will be automatically selected when a new session spawns. You can also reference it by the alias like this:
nvm use default
Each version of Node.js will keep track of its own packages and has npm available to manage these.

Can somebody please tell me if I am using the wrong node js version?

I have been trying to update nodejs for a long time now. When I run node -v, it tells me I am using: v0.10.40. But when I look at nodejs.org it says the v7.4.0?
I have cleaned the npm cache and done a reinstall with sudo n stable but still v0.10.40, and the last time that I updated npm it prompted me that my node version is too old and outdated.
What am I doing wrong. And can somebody tell me if v0.10.40 is the current or an outdated version?
You likely have two versions of node installed and in your path. If you are on OSX or linux, run which node (if on Windows, you may npm i -g #raider/which, and then run which node). This should give you the location of the old version of node.
Then run mv path/to/old/node path/to/old/node.bak, replacing with the actual path, and rerun node --version to see if it picks up the right version now.
UPDATE: If you are on Ubuntu or another Debian based Linux, you should install the latest with the following commands:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
UPDATE: If you are using nvm, run nvm install node followed by nvm use node in a new terminal to get the latest that nvm supports.

How to upgrade Node js version to 0.12.4 on Ubuntu

I want to upgrade Node JS version on Ubuntu.
I tried many commands but its version is still the older i.e v0.10.37.
I tried:
sudo npm install -g n
sudo n install 0.12.4
sudo n use 0.12.4
Also tried with nvm but non of them works for me. How can I upgrade Node Js version to 0.12.4?
Use npm in order to upgrade node
First Clean the cache and try
sudo npm cache clean -f
sudo npm install -g n
sudo n 0.12.4
Then create a symbolic link(It is needed only sometimes, first try with these three commands. If it doesnot work add this.)
It will be updated to 0.12.4 Version.
It could be enough just to install n module:
sudo npm install -g n
and then simply run:
sudo n 0.12.4
The trick is that it may not be updated in your current terminal session. So you can simply open one more tab in your terminal or just another terminal and check your nodejs version by:
node --version
That's it, output will be v0.12.4
The official doc from nodejs repository points to this : https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories#installing-node-js-v0-12
Just follow it and you'll have the 0.12.4.
Try running this in terminal:
nvm install 5.10.1
nvm use 5.10.1
The version may be change.
Cheers!
Execute following comand to upgrade nodejs to 0.12.x
Note the new setup script name for Node.js v0.12
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
Then install with:
sudo apt-get install -y nodejs
Just ignore warning. By executing both commands it worked for me on Ubuntu 14.04
On Ubuntu 16.04
There is no special or dedicated comand to upgrade node version. The correct way to install or upgrade node on ubuntu is:
1) download the distribution you wish from nodejs official site, move the file into a known path
2) open a terminal and run: >sudo tar -C /usr/local --strip-components 1 -xzf "known path/name_of_the_distribution_file...gz
3) test if everything is ok: open a new terminal and run node --version. It should echo the version you downloaded and installed/upgraded.

Gulp global installation not possible [duplicate]

NodeJS interpreter name(node) on Ubuntu has been renamed to nodejs because of a name conflict with another package. Here's what the readme. Debian says:
The upstream name for the Node.js interpreter command is "node".
In Debian the interpreter command has been changed to "nodejs".
This was done to prevent a namespace collision: other commands use
the same name in their upstream, such as ax25-node from the "node"
package.
Scripts calling Node.js as a shell command must be changed to instead
use the "nodejs" command.
However, using nodejs mucks up installing packages using npm. Package installation fails with the following error:
sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian
How do I make npm understand that nodejs is already installed on the system but the interpreter name is different?
TL;DR:
sudo apt-get install nodejs-legacy
First of all let me clarify the situation a bit. In summer 2012 Debian maintainers decided to rename Node.js executable to prevent some kind of namespace collision with another package. It was very hard decision for Debian Technical Committee, because it breaks backward compatibility.
The following is a quote from Committee resolution draft, published in Debian mailing list:
The nodejs package shall be changed to provide /usr/bin/nodejs, not /usr/bin/node. The package should declare a Breaks: relationship with
any packages in Debian that reference /usr/bin/node.
The nodejs source package shall also provide a nodejs-legacy binary package at Priority: extra that contains /usr/bin/node as a symlink to
/usr/bin/nodejs. No package in the archive may depend on or recommend
the nodejs-legacy package, which is provided solely for upstream
compatibility. This package declares shall also declare a Conflicts:
relationship with the node package.
<...>
Paragraph 2 is the actual solution for OP's issue. OP should try to install this package instead of doing symlink by hand. Here is a link to this package in Debian package index website.
It can be installed using sudo apt-get install nodejs-legacy.
I have not found any information about adopting the whole thing by NPM developers, but I think npm package will be fixed on some point and nodejs-legacy become really legacy.
Try linking node to nodejs. First find out where nodejs is
whereis nodejs
Then soft link node to nodejs
ln -s [the path of nodejs] /usr/bin/node
I am assuming /usr/bin is in your execution path. Then you can test by typing node or npm into your command line, and everything should work now.
You can also install Nodejs using NVM or Nodejs Version Manager There are a lot of benefits to using a version manager. One of them being you don't have to worry about this issue.
Instructions:
sudo apt-get update
sudo apt-get install build-essential libssl-dev
Once the prerequisite packages are installed, you can pull down the nvm installation script from the project's GitHub page. The version number may be different, but in general, you can download and install it with the following syntax:
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
This will download the script and run it. It will install the software into a subdirectory of your home directory at ~/.nvm. It will also add the necessary lines to your ~/.profile file to use the file.
To gain access to the nvm functionality, you'll need to log out and log back in again, or you can source the ~/.profile file so that your current session knows about the changes:
source ~/.profile
Now that you have nvm installed, you can install isolated Node.js versions.
To find out the versions of Node.js that are available for installation, you can type:
nvm ls-remote
. . .
v0.11.10
v0.11.11
v0.11.12
v0.11.13
v0.11.14
As you can see, the newest version at the time of this writing is v0.11.14. You can install that by typing:
nvm install 0.11.14
Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:
nvm use 0.11.14
When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:
node -v
The comeplete tutorial can be found here
Install nvm first using:
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
Run command
source ~/.profile
Now run this and this will show will all installed or other versions of packages:
nvm ls-remote
Installed packages will be in green. Install whatever version you want:
nvm install 6.0.0
Check where is not installed:
which node
Check current version:
node -v
n=$(which node);
n=${n%/bin/node};
chmod -R 755 $n/bin/*;
sudo cp -r $n/{bin,lib,share} /usr/local
sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs-legacy
sudo apt-get --purge remove nodejs
sudo apt-get install nodejs-legacy
source ~/.profile
Combined the accepted answer with source ~/.profile from the comment that has been folded and some clean up commands before. Most likely you will also need to sudo apt-get install npm after.
for me problem was solved by,
sudo apt-get remove node
sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node
alias node=nodejs
rm -r /usr/local/lib/python2.7/dist-packages/localstack/node_modules
npm install -g npm#latest || sudo npm install -g npm#latest
Here's another approach I use since I like n for easy switching between node versions.
On a new Ubuntu system, first install the 'system' node:
curl -sL https://deb.nodesource.com/setup | sudo bash -
Then install n module globally:
npm install -g n
Since the system node was installed first (above), the alternatives system can be used to cleanly point to the node provided by n. First make sure the alternatives system has nothing for node:
update-alternatives --remove-all node
Then add the node provided by n:
update-alternatives --install /usr/bin/node node /usr/local/bin/node 1
Next add node provided by the system (the one that was installed with curl):
update-alternatives --install /usr/bin/node node /usr/bin/nodejs 2
Now select the node provided by n using the interactive menu (select /usr/local/bin/node from the menu presented by the following command):
update-alternatives --config node
Finally, since /usr/local/bin usually has a higher precedence in PATH than /usr/bin, the following alias must be created (enter in your .bashrc or .zshrc) if the alternatives system node is to be effective; otherwise the node installed with n in /usr/local/bin takes always precedence:
alias node='/usr/bin/node'
Now you can easily switch between node versions with n <desired node version number>.
On Linux Mint 17, I tried both solutions (creating a symlink or using the nodejs-legacy package) without success.
The only thing that finally worked for me was using the ppa from Chris Lea:
sudo apt-get purge node-*
sudo apt-get autoremove
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
This installed node version 10.37 and npm 1.4.28. After that, I could install packages globally.
As other folks already mention, I will suggest not to use "sudo apt-get" to install node or any development library. You can download required version from https://nodejs.org/dist/v6.9.2/ and setup you own environment.
I will recommend tools like nvm and n, to manage you node version. It is very convenient to switch and work with these modules.
https://github.com/creationix/nvm
https://github.com/tj/n
Or write basic bash to download zip/tar, extract move folder and create a soft link. Whenever you need to update, just point the old soft link to new downloaded version.
Like I have created for my own, you can refer:
https://github.com/deepakshrma/NodeJs-4.0-Reference-Guide/blob/master/nodejs-installer.sh
#Go to home
cd ~
#run command
#New Script
wget https://raw.githubusercontent.com/deepakshrma/NodeJs-4.0-Reference-Guide/master/nodejs-installer.sh
bash nodejs-installer.sh -v lts
#here -v or --version can be sepecific to 0.10.37 or it could be latest/lts
#Examples
bash nodejs-installer.sh -v lts
bash nodejs-installer.sh -v latest
bash nodejs-installer.sh -v 4.4.2
Simple solution from here
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash --
sudo apt-get install nodejs
You can specify version by changing setup_x.x value, for example to setup_5.x
Your System is not able to detect the path node js binary.
1.which node
2.Then soft link node to nodejs
ln -s [the path of nodejs] /usr/bin/node
I am assuming /usr/bin is in your execution path. Then you can test by typing node or npm into your command line, and everything should work now.
Uninstall whatever node version you have
sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs-legacy
sudo apt-get --purge remove nodejs
install nvm (Node Version Manager) https://github.com/creationix/nvm
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
Now you can install whatever version of node you want and switch between the versions.
I fixed it unlinking /usr/sbin/node (which is linked to ax25-node package), then I have create a link to nodejs using this on command line
sudo ln -s /usr/bin/nodejs /usr/bin/node
Because package such as karma doesn't work with nodejs name, however changing the first line of karma script from node to nodejs, but I prefer resolve this issue once and for all
For me the fix was removing the node* packages and also the npm packages.
Then a fresh install as:
sudo apt-get install autoclean
sudo apt-get install nodejs-legacy
npm install
Problem is not in installer
replace nodejs with node or change the path from /usr/bin/nodejs to /usr/bin/node
This is the your node is not properly install, first you need to uninstall the node then install again.
To install the node this may help you
http://array151.com/blog/nodejs-tutorial-and-set-up/
after that you can install the packages easily. To install the packages this may help you
http://array151.com/blog/npm-node-package-manager/
you can create a link ln -s nodejs node in /usr/bin
hope this solves your problem.
node -v // first check it's install or not
npm -v
sudo apt install npm
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash –
sudo apt-get install nodejs
then check
node -v or node –version
npm -v or npm –version
or you can remove package.lock json file / node_modules than run npm i
I hope it'll work fine
steps : https://www.geeksforgeeks.org/installation-of-node-js-on-linux/
Faced same issue, steps below worked for me.
Install curl on your system then run NVM installer script.
sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Load the environment
source ~/.profile
Install the supported version of Node.js.
nvm install 16.15.1
Confirm the installation
node -v

Cannot install packages using node package manager in Ubuntu

NodeJS interpreter name(node) on Ubuntu has been renamed to nodejs because of a name conflict with another package. Here's what the readme. Debian says:
The upstream name for the Node.js interpreter command is "node".
In Debian the interpreter command has been changed to "nodejs".
This was done to prevent a namespace collision: other commands use
the same name in their upstream, such as ax25-node from the "node"
package.
Scripts calling Node.js as a shell command must be changed to instead
use the "nodejs" command.
However, using nodejs mucks up installing packages using npm. Package installation fails with the following error:
sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian
How do I make npm understand that nodejs is already installed on the system but the interpreter name is different?
TL;DR:
sudo apt-get install nodejs-legacy
First of all let me clarify the situation a bit. In summer 2012 Debian maintainers decided to rename Node.js executable to prevent some kind of namespace collision with another package. It was very hard decision for Debian Technical Committee, because it breaks backward compatibility.
The following is a quote from Committee resolution draft, published in Debian mailing list:
The nodejs package shall be changed to provide /usr/bin/nodejs, not /usr/bin/node. The package should declare a Breaks: relationship with
any packages in Debian that reference /usr/bin/node.
The nodejs source package shall also provide a nodejs-legacy binary package at Priority: extra that contains /usr/bin/node as a symlink to
/usr/bin/nodejs. No package in the archive may depend on or recommend
the nodejs-legacy package, which is provided solely for upstream
compatibility. This package declares shall also declare a Conflicts:
relationship with the node package.
<...>
Paragraph 2 is the actual solution for OP's issue. OP should try to install this package instead of doing symlink by hand. Here is a link to this package in Debian package index website.
It can be installed using sudo apt-get install nodejs-legacy.
I have not found any information about adopting the whole thing by NPM developers, but I think npm package will be fixed on some point and nodejs-legacy become really legacy.
Try linking node to nodejs. First find out where nodejs is
whereis nodejs
Then soft link node to nodejs
ln -s [the path of nodejs] /usr/bin/node
I am assuming /usr/bin is in your execution path. Then you can test by typing node or npm into your command line, and everything should work now.
You can also install Nodejs using NVM or Nodejs Version Manager There are a lot of benefits to using a version manager. One of them being you don't have to worry about this issue.
Instructions:
sudo apt-get update
sudo apt-get install build-essential libssl-dev
Once the prerequisite packages are installed, you can pull down the nvm installation script from the project's GitHub page. The version number may be different, but in general, you can download and install it with the following syntax:
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
This will download the script and run it. It will install the software into a subdirectory of your home directory at ~/.nvm. It will also add the necessary lines to your ~/.profile file to use the file.
To gain access to the nvm functionality, you'll need to log out and log back in again, or you can source the ~/.profile file so that your current session knows about the changes:
source ~/.profile
Now that you have nvm installed, you can install isolated Node.js versions.
To find out the versions of Node.js that are available for installation, you can type:
nvm ls-remote
. . .
v0.11.10
v0.11.11
v0.11.12
v0.11.13
v0.11.14
As you can see, the newest version at the time of this writing is v0.11.14. You can install that by typing:
nvm install 0.11.14
Usually, nvm will switch to use the most recently installed version. You can explicitly tell nvm to use the version we just downloaded by typing:
nvm use 0.11.14
When you install Node.js using nvm, the executable is called node. You can see the version currently being used by the shell by typing:
node -v
The comeplete tutorial can be found here
Install nvm first using:
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
Run command
source ~/.profile
Now run this and this will show will all installed or other versions of packages:
nvm ls-remote
Installed packages will be in green. Install whatever version you want:
nvm install 6.0.0
Check where is not installed:
which node
Check current version:
node -v
n=$(which node);
n=${n%/bin/node};
chmod -R 755 $n/bin/*;
sudo cp -r $n/{bin,lib,share} /usr/local
sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs-legacy
sudo apt-get --purge remove nodejs
sudo apt-get install nodejs-legacy
source ~/.profile
Combined the accepted answer with source ~/.profile from the comment that has been folded and some clean up commands before. Most likely you will also need to sudo apt-get install npm after.
for me problem was solved by,
sudo apt-get remove node
sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node
alias node=nodejs
rm -r /usr/local/lib/python2.7/dist-packages/localstack/node_modules
npm install -g npm#latest || sudo npm install -g npm#latest
Here's another approach I use since I like n for easy switching between node versions.
On a new Ubuntu system, first install the 'system' node:
curl -sL https://deb.nodesource.com/setup | sudo bash -
Then install n module globally:
npm install -g n
Since the system node was installed first (above), the alternatives system can be used to cleanly point to the node provided by n. First make sure the alternatives system has nothing for node:
update-alternatives --remove-all node
Then add the node provided by n:
update-alternatives --install /usr/bin/node node /usr/local/bin/node 1
Next add node provided by the system (the one that was installed with curl):
update-alternatives --install /usr/bin/node node /usr/bin/nodejs 2
Now select the node provided by n using the interactive menu (select /usr/local/bin/node from the menu presented by the following command):
update-alternatives --config node
Finally, since /usr/local/bin usually has a higher precedence in PATH than /usr/bin, the following alias must be created (enter in your .bashrc or .zshrc) if the alternatives system node is to be effective; otherwise the node installed with n in /usr/local/bin takes always precedence:
alias node='/usr/bin/node'
Now you can easily switch between node versions with n <desired node version number>.
On Linux Mint 17, I tried both solutions (creating a symlink or using the nodejs-legacy package) without success.
The only thing that finally worked for me was using the ppa from Chris Lea:
sudo apt-get purge node-*
sudo apt-get autoremove
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
This installed node version 10.37 and npm 1.4.28. After that, I could install packages globally.
As other folks already mention, I will suggest not to use "sudo apt-get" to install node or any development library. You can download required version from https://nodejs.org/dist/v6.9.2/ and setup you own environment.
I will recommend tools like nvm and n, to manage you node version. It is very convenient to switch and work with these modules.
https://github.com/creationix/nvm
https://github.com/tj/n
Or write basic bash to download zip/tar, extract move folder and create a soft link. Whenever you need to update, just point the old soft link to new downloaded version.
Like I have created for my own, you can refer:
https://github.com/deepakshrma/NodeJs-4.0-Reference-Guide/blob/master/nodejs-installer.sh
#Go to home
cd ~
#run command
#New Script
wget https://raw.githubusercontent.com/deepakshrma/NodeJs-4.0-Reference-Guide/master/nodejs-installer.sh
bash nodejs-installer.sh -v lts
#here -v or --version can be sepecific to 0.10.37 or it could be latest/lts
#Examples
bash nodejs-installer.sh -v lts
bash nodejs-installer.sh -v latest
bash nodejs-installer.sh -v 4.4.2
Simple solution from here
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash --
sudo apt-get install nodejs
You can specify version by changing setup_x.x value, for example to setup_5.x
Your System is not able to detect the path node js binary.
1.which node
2.Then soft link node to nodejs
ln -s [the path of nodejs] /usr/bin/node
I am assuming /usr/bin is in your execution path. Then you can test by typing node or npm into your command line, and everything should work now.
Uninstall whatever node version you have
sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs-legacy
sudo apt-get --purge remove nodejs
install nvm (Node Version Manager) https://github.com/creationix/nvm
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
Now you can install whatever version of node you want and switch between the versions.
I fixed it unlinking /usr/sbin/node (which is linked to ax25-node package), then I have create a link to nodejs using this on command line
sudo ln -s /usr/bin/nodejs /usr/bin/node
Because package such as karma doesn't work with nodejs name, however changing the first line of karma script from node to nodejs, but I prefer resolve this issue once and for all
For me the fix was removing the node* packages and also the npm packages.
Then a fresh install as:
sudo apt-get install autoclean
sudo apt-get install nodejs-legacy
npm install
Problem is not in installer
replace nodejs with node or change the path from /usr/bin/nodejs to /usr/bin/node
This is the your node is not properly install, first you need to uninstall the node then install again.
To install the node this may help you
http://array151.com/blog/nodejs-tutorial-and-set-up/
after that you can install the packages easily. To install the packages this may help you
http://array151.com/blog/npm-node-package-manager/
you can create a link ln -s nodejs node in /usr/bin
hope this solves your problem.
node -v // first check it's install or not
npm -v
sudo apt install npm
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash –
sudo apt-get install nodejs
then check
node -v or node –version
npm -v or npm –version
or you can remove package.lock json file / node_modules than run npm i
I hope it'll work fine
steps : https://www.geeksforgeeks.org/installation-of-node-js-on-linux/
Faced same issue, steps below worked for me.
Install curl on your system then run NVM installer script.
sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Load the environment
source ~/.profile
Install the supported version of Node.js.
nvm install 16.15.1
Confirm the installation
node -v

Resources