# Illegal Instruction after npm install on old pi zero, but ok using install script

**URL:** <https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487>\
**Category:** General\
**Created:** [18 February 2025 13:29 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487 "2025-02-18T13:29:46Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 February 2025 13:29 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/1 "2025-02-18T13:29:46Z")

</div>

As mentioned in [this post](https://discourse.nodered.org/t/node-red-4-0-9-released/95410/6) I installed node-red on an original Pi zero [using the recommended install script](https://nodered.org/docs/getting-started/raspberrypi). It installed node red 4.0.9 and nodejs 20 and node-red runs fine.

However, I find that if I npm remove node-red (leaving nodejs20 installed) and then re-install the same version using of node-red using  
`sudo npm install -g --unsafe-perm node-red`  
then when I run node-red it just says `Illegal Instruction`.

If I then remove node-red again run the script again then all is once more working.

In the failing mode I tried running `npm rebuild` in /usr/lib and in the .node-red directory but that made no difference.

I am guessing that for some reason the wrong architecture of something is being installed, but can't see what the difference is when run via the script. Has anyone any ideas?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 February 2025 14:35 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/2 "2025-02-18T14:35:20Z")

</div>

Do you have the Linux build tools installed on the Pi? I'm wondering if something is trying to compile a binary library and failing for some reason?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 February 2025 15:41 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/3 "2025-02-18T15:41:40Z")

</div>

> [@TotallyInformation](#):
>
> Do you have the Linux build tools installed on the Pi

Yes.  
There are no errors that I can see, I increased the log level on npm and nothing looks out of place.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 February 2025 15:44 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/4 "2025-02-18T15:44:05Z")

</div>

OK, next step would be to increase the verbosity of the npm install to see if that throws up any clues.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 February 2025 16:10 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/5 "2025-02-18T16:10:58Z")

</div>

I am running it with loglevel verbose now. If nothing obvious I will hack the install script to do the same and see if there are any differences.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 February 2025 21:17 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/6 "2025-02-18T21:17:46Z")

</div>

I am getting somewhere now. It isn't the install itself that is different. I inserted an `exit` statement in the script right after the install and then I get the illegal instruction error again. I will have to look carefully at what comes after. I am not installing the pi specific nodes so it isn't that.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 February 2025 21:25 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/7 "2025-02-18T21:25:26Z")

</div>

I have found it, I should have seen it hours ago. I thought I had looked through this bit of the script, but there I now see

```auto
            # If armv6 then remove the bcrypt binary to workaround illegal instruction error
            if uname -m | grep -q armv6l ; then
                $SUDO rm -rf /usr/lib/node_modules/node-red/node_modules/@node-rs | $SUDO tee -a /var/log/nodered-install.log >>/dev/null
            fi

```

Doh!

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [19 February 2025 01:22 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/8 "2025-02-19T01:22:12Z")

</div>

> [@Colin](#):
>
> `bcrypt binary`

Yup, as expected, a C library that requires compilation. Presumably not compatible with whatever C compiler is present on that device. I vaguely seem to remember that it has a JavaScript fallback version?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 February 2025 10:39 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/9 "2025-02-19T10:39:52Z")

</div>

> [@TotallyInformation](#):
>
> a C library that requires compilation

It doesn't try and build it, I think the problem is that it is provided as a pre-compiled binary and is not available for armv6 architecture.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [19 February 2025 10:42 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/10 "2025-02-19T10:42:59Z")

</div>

Ah, OK. I think it should try to build it if a pre-built version doesn't exist. Possibly the make config for armv6 has been removed if it is no longer supported.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 February 2025 22:16 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/11 "2025-02-19T22:16:57Z")

</div>

Well (re) found. I had forgotten about that.. I must have been having a good day to suss that out originally 🙂

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 February 2025 07:28 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/12 "2025-02-20T07:28:42Z")

</div>

Do you know why npm installs an invalid version rather than trying to build it from source, or at least throwing an error?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 February 2025 10:25 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/13 "2025-02-20T10:25:06Z")

</div>

Sorry Colin, can't remember whether you said this. But did you try installing the raw library into a dummy npm package? Does it give the same error? I don't have any Pi Zero's to try it on I'm afraid.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [20 February 2025 13:35 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/14 "2025-02-20T13:35:44Z")

</div>

Can’t recall, but as we also install a pure js version as a backup it was easier just to go with that rather than suffer the vagaries of build tools

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [25 February 2025 14:53 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/15 "2025-02-25T14:53:03Z")

</div>

ahem, cough 😉

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [25 February 2025 14:58 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/16 "2025-02-25T14:58:53Z")

</div>

Because ARMv6 is not an officially supported NodeJS platform any more (and hasn't been for a while now, 2019 ish [RFC: Consider retiring the PI1s ARMv6 (downgrading support to "experimental") · Issue #1677 · nodejs/build · GitHub](https://github.com/nodejs/build/issues/1677#issuecomment-465326568)).

And because bycrypt has a collection of pre-built binaries and doesn't have a way to tell the difference between ARMv6 and ARMv7 based on the information provided by NodeJS so it just downloads the 32bit Arm version of it's pre-built binaries and they stopped building that binary with ARMv6 support after it was no longer a supported target.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 February 2025 15:34 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/17 "2025-02-25T15:34:32Z")

</div>

> [@hardillb](#):
>
> doesn't have a way to tell the difference between ARMv6 and ARMv7 based on the information provided by NodeJS

Understood. Thanks.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [25 February 2025 22:22 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/18 "2025-02-25T22:22:26Z")

</div>

Ah yes. Told you I forgot ! It was Ben that sussed it all out originally ! Thanks Ben

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 March 2025 22:22 UTC](https://discourse.nodered.org/t/illegal-instruction-after-npm-install-on-old-pi-zero-but-ok-using-install-script/95487/19 "2025-03-11T22:22:39Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
