简体   繁体   中英

Trying to install Node.js 12 on a Raspberry Pi, somehow ending up with version 10 instead

I'm trying create a bash installation script to install Node.js version 12 on a Raspberry Pi using:

curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -
sudo apt-get install -y nodejs

When the installation is done, however, I check the version with node --version , and I've got v10.24.0 instead.

What would cause this, and how do I stop it from happening?

I'm also finding that npm isn't installed unless I instead do:

sudo apt-get install -y nodejs npm

...and make the installation of npm explicit. This sort of works, but then I get warnings every time I use npm that npm isn't really meant to be used with Node 10.

Am I perhaps missing some prerequisite for version 12, and being automatically downgraded to version 10?

I'm trying to to get this to work with a Raspberry Pi 3B+ with only 1GB RAM. Could that be the issue? My intention was to deliberately install 12 instead of 14 in this installation script if I detect less than 2GB RAM, because I think 14 might require more than 1GB to run reliably. Maybe 1GB is too small for 12 too?

If I try to install again, I get:

pi@raspberry:~ $ sudo apt-get install -y nodejs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
nodejs is already the newest version (10.24.0~dfsg-1~deb10u1).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

Note: For most of my testing, I'm not using a real Raspberry Pi, but a VM with Debian Linux 10.8 and a Raspberry Pi desktop. The problems are the same on the real hardware, however. The VM just makes testing a LOT faster.

Remove the installed version:

sudo apt purge nodejs

Download the tarball from here , extact it then copy it to /usr/local/ (use uname -a the get the exact ARMv* version):

wget https://nodejs.org/dist/v12.9.1/node-v12.9.1-linux-armv7l.tar.xz
unxz node-v12.9.1-linux-armv7l.tar.xz
tar xvf node-v12.9.1-linux-armv7l.tar
cd node-v12.9.1-linux-armv7l/
sudo cp -R * /usr/local/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM