I installed node 16, on Ubuntu 20.04 (WSL on Windows10) using these commands:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
And it gets the right package
Unpacking nodejs (16.13.1-deb-1nodesource1) ...
Setting up nodejs (16.13.1-deb-1nodesource1) ...
But somehow, I get node 14
$ node -v
v14.15.5
I had nodejs installed already before I tried to upgrade to 16 but I am pretty sure the installer removed it.
I tried to remove the package nodejs and installagain , I ran apt autoremove, I checked /etc/apt/sources.list.d/nodesource.list and there is only the node_16.x PPA...
What did I miss? Where is that node 14 coming from?
My bad... Turns out it was emscripten who had installed another NodeJS in its own app folder and was setting that in the env.
I just deleted the node directory in the emsdk folder and it's working.
Edit: I had compilation issues on MacOS when I removed the node directory because emscripten was using system libs that were probably not matching its expectations. So I had to restore it (using emsdk install SOME_VERSION).
Related
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.
I am having trouble installing&running nodejs on my ubuntu 18 pc.
I run following commands step by step:
sudo apt update
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt -y install nodejs
And later checked the version number:
node -v
v8.10.0
Later I removed nodejs and i tried to install nodejs 12, 13 and 11, every time it is installing v8.10.0.
Can anyone please help me in this case?
My theory is that node 8 is installed no matter what and that it's in your PATH with a higher priority. Try uninstalling all versions of node and run node -v to verify that. If that's the case, I suggest you try to find a way to uninstall that version of node before reinstalling the version you want.
Also by typing which node you can get the path of the current executable that is being called when you call the node command. It may be a symlink in which case ls -l of the returned path would show you to path pointed by it.
Anyway, I suggest using nvm (Node Version Manager). Documentation at https://nvm.sh
Guess it's nvm, run
nvm ls to list all the node versions
nvm use <node version you want to use>
nvm current to check the node version in use
I'm trying to get Expo, a platform for making native mobile apps, to run on a Windows 10 machine. A preprequisite for Expo is NodeJS so I installed that. However, I ran into some issues getting Expo to work using Git Bash and so now I'm trying to get Windows Subsystem for Linux (WSL) operational to use that instead. Ubuntu 18.04 LTS has been downloaded and initialized. Using a CMD here is what's happening:
C:\Users\jason.black>node -v
v12.13.0
C:\Users\jason.black>wsl
jason#PC1:/mnt/c/Users/jason.black$ node -v
Command 'node' not found, but can be installed with:
sudo apt install nodejs
jason#PC1:/mnt/c/Users/jason.black$ sudo apt install nodejs
[sudo] password for jason:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package nodejs
jason#PC1:/mnt/c/Users/jason.black$
So it appears that NodeJS which was initially installed is not available to WSL. Does that seem right? And why won't it install so WSL can access it?
If you're trying to access Node installed on the windows site, you may specify the PATH to /mnt/x/.../path/to/node/bin; if you're trying to install nodejs on the Linux side, may be you're looking for the package 'node' (not nodejs), or you can just download the portable version: https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz
For someone who's not familiar to Linux:
# will be download to home directory
cd ~
# using wget
wget https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz
# using curl
curl -o node-v12.13.1-linux-x64.tar.xz https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz
# extract
tar xf node-v12.13.1-linux-x64.tar.xz
Issue: Unable to start Node server
Platform: Bash on Ubuntu on Windows 10
Currently following tutorial that builds a blog on MEAN
Commands ran after installation:
apt-get install npm
npm init
npm install express --save
node server.js
Last command node server.js supposed to start Node server.
But nothing happens on my bash command line.
server.js codes:
command node-v (node version not found):
However, Node is already installed:
Accessing localhost:3000
On Ubuntu (and Debian as well), the correct package to install for Node.js is called nodejs:
$ sudo apt-get install nodejs
However, my experience is that this generally installs an outdated version of Node, which isn't great. It also installs the interpreter with the executable name nodejs, not node as you would expect.
Alternatively, you can add the official binary distribution repositories for Node.js, which allows you to install more recent versions of Node (v6 or even v7). These are also kept up-to-date much better than the Ubuntu/Debian repositories.
The process is documented here, but if you want to install Node v6, you would run this code:
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs
It's probably best to remove any previously installed packages (npm, node, nodejs) before running the commands above.
I installed both node.js and forever.js and when I run them in my terminal (bash on Ubuntu 14.04), nothing happens.
So, it looks like:
#node
#
or
#forever
#forever --help
#forever listall
#
Everything else not node-related runs fine.
There was something wrong with apt-get, so when installing node, it didn't actually install node, but it did put a program in the path that did seemingly nothing.
I uninstalled it with
apt-get purge node
Then, I downloaded the 64-bit linux binary from here: http://nodejs.org/download/
And I extracted it with tar -xvf filename, then I set that directory/bin to the path with:
PATH=$PATH:/directory/to/node/bin
And now it works fine. The forever issue was because the node installed wasn't node at all, but instead a 30kb program of some sort, I don't know.
Here's the information about the program that was installed via apt-get install node:
Package: node
Priority: optional
Section: universe/hamradio
Installed-Size: 38
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
Original-Maintainer: Debian Hamradio Maintainers <debian-hams#lists.debian.org>
Architecture: all
Version: 0.3.2-7.4
Depends: ax25-node
Conflicts: nodejs-legacy
Filename: pool/universe/n/node/node_0.3.2-7.4_all.deb
Size: 1284
MD5sum: 7385a0f5916e03d9143459ca4706f0ec
SHA1: bf7aa087db81475636897ff39de344754ce1415b
SHA256: 9756770f771bcc4183cffa622f89e21a585be96bd4de27024b0a7cb167f310ad
Description-en: Amateur Packet Radio Node program (transitional package)
The existing node package has been renamed to ax25-node. This transitional
package exists to ease the upgrade path for existing users.
Description-md5: 1278ed271672fd829c99361f93f468da
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
So, I also found that the correct way to install node with apt-get is apt-get install nodejs.
I had the same issue, and I think it was caused because I naively apt-get installed node first. Doing a
sudo apt-get purge node
Followed by the instructions on the web here (https://github.com/nodesource/distributions):
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
fixed the issue for me. node doesn't exist, but nodejs does and other tools work (like slap) now.
EDIT: On one server I updated, node did exist. Not sure exactly what order things need to happen in, but whatever...
I was having this issue, I found that to solve the issue, I needed to remove the node file within /usr/sbin/node (found with which node) and replace it with a hard link to /usr/bin/nodejs (found with which nodejs)
ln /usr/bin/nodejs /usr/sbin/node
Just run nodejs command on your terminal after installing nodejs package.
It will give you the JavaScript prompt or interpreter.
The problem you are having is that apt-get installed NodeJS under the binary nodejs. Also when you do a npm install forever -g it also expects the binary to be node.
To verify this you can do a
% which forever
lrwxrwxrwx 1 root root 39 Jan 25 21:34 /usr/local/bin/forever -> ../lib/node_modules/forever/bin/forever
to find the location of the forever script.
Then check the node binary it's trying to execute.
% vim /usr/local/lib/node_modules/forever/bin/forever
#!/usr/bin/env node
This /usr/bin/env node needs to be changed to /usr/bin/env nodejs.
But to bypass this problem you should definitely look into using upstart.
http://howtonode.org/deploying-node-upstart-monit