[英]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:我正在尝试创建一个 bash 安装脚本以在 Raspberry Pi 上安装 Node.js 版本 12,使用:
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.但是,安装完成后,我使用
node --version
检查版本,而我得到的是 v10.24.0。
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:我还发现没有安装
npm
,除非我这样做:
sudo apt-get install -y nodejs npm
...and make the installation of npm
explicit. ...并明确安装
npm
。 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.这种工作,但我每次使用
npm
时都会收到警告,指出npm
并不是真的要与节点 10 一起使用。
Am I perhaps missing some prerequisite for version 12, and being automatically downgraded to version 10?我是否可能缺少版本 12 的一些先决条件,并被自动降级到版本 10?
I'm trying to to get this to work with a Raspberry Pi 3B+ with only 1GB RAM.我试图让它与只有 1GB RAM 的 Raspberry Pi 3B+ 一起工作。 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.
如果我检测到小于 2GB 的 RAM,我的意图是故意在此安装脚本中安装 12 而不是 14,因为我认为 14 可能需要超过 1GB 才能可靠运行。 Maybe 1GB is too small for 12 too?
也许 1GB 对于 12 来说也太小了?
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.注意:对于我的大部分测试,我使用的不是真正的 Raspberry Pi,而是带有 Debian Linux 10.8 和 Raspberry Pi 桌面的 VM。 The problems are the same on the real hardware, however.
但是,实际硬件上的问题是相同的。 The VM just makes testing a LOT faster.
VM 只是让测试更快。
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):从这里下载 tarball,解压,然后将其复制到
/usr/local/
(使用uname -a
获取确切的ARMv*
版本):
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/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.