Open nophead opened 1 year ago
Great question. Yeah, I'm not sure why Node doesn't publish builds for ARMv6 anymore, although many other apps do as well. Fortunately the Zero 2 is a newer ARM that is supported so going forward this won't be needed, but I digress...
You'll need to either compile Node.js yourself or download a precompiled binary that does support ARMv6. Fortunately, there are "unofficial" builds that are available that just work.
I wrote a whole script to build Pi images and included a feature to install Node for ARMv6.
Or you can just run these commands on your Pi Zero:
VERSION=$(curl -s https://unofficial-builds.nodejs.org/download/release/index.tab | tail -n+2 | head -n1 | cut -f1) # Latest
VERSION=$(curl -s https://unofficial-builds.nodejs.org/download/release/index.tab | tail -n+2 | awk '$10!="-"' - | head -n1 | cut -f1) # LTS
URL=https://unofficial-builds.nodejs.org/download/release/${VERSION}/node-${VERSION}-linux-armv6l.tar.xz
curl "${URL}" | sudo tar xJ -C /usr/local --strip-components=1
I should add that this project is really in a skeleton state. Not much really works yet.
Thanks, that enabled me to install Node.js and it seems to be working. However, when I run npm i
in the toaster directory I get the following error:
pi@T-962:~/toaster $ npm i
npm ERR! code 1
npm ERR! path /home/pi/toaster/node_modules/node
npm ERR! command failed
npm ERR! command sh -c node installArchSpecificPackage
npm ERR! npm ERR! code E404
npm ERR! npm ERR! 404 Not Found - GET https://registry.npmjs.org/node-linux-arm - Not found
npm ERR! npm ERR! 404
npm ERR! npm ERR! 404 'node-linux-arm@19.8.1' is not in this registry.
npm ERR! npm ERR! 404
npm ERR! npm ERR! 404 Note that you can also install from a
npm ERR! npm ERR! 404 tarball, folder, http url, or git url.
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in: /home/pi/.npm/_logs/2023-10-10T16_13_29_005Z-debug-0.log
npm ERR! node:internal/modules/cjs/loader:1051
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Cannot find module 'node-linux-arm/package.json'
npm ERR! Require stack:
npm ERR! - /home/pi/toaster/node_modules/node/installArchSpecificPackage.js
npm ERR! at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
npm ERR! at Function.resolve (node:internal/modules/helpers:136:19)
npm ERR! at ChildProcess.<anonymous> (/home/pi/toaster/node_modules/node-bin-setup/index.js:19:27)
npm ERR! at ChildProcess.emit (node:events:514:28)
npm ERR! at maybeClose (node:internal/child_process:1105:16)
npm ERR! at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! requireStack: [
npm ERR! '/home/pi/toaster/node_modules/node/installArchSpecificPackage.js'
npm ERR! ]
npm ERR! }
npm ERR!
npm ERR! Node.js v20.8.0
npm ERR! A complete log of this run can be found in: /home/pi/.npm/_logs/2023-10-10T16_09_03_288Z-debug-0.log
Looks like the registry path should be https://registry.npmjs.org/node-linux-armv6l but I don't know where it comes from.
Forgive my ignorance but the RPI0 in your pictures seems to an RPI0 W, which is arm6l. Nodejs version 12 seems to the last to support arm6l. https://github.com/orgs/nodejs/discussions/38496.
The default version on Raspbian seems to be v12.22.12 but npm -i wants version 14 or 16 for some libraries.