3

New to using a nodejs environment on a Pi.

I'm using a RPi 4B with Debian GNU/Linux 11 (bullseye) with nodejs v12.22.12 and npm v7.5.2. Latest nodejs is supposed to be v19, npm v9. I tried updating node and npm as follows:

$ sudo apt update
$ sudo apt full-upgrade
$ sudo reboot

But npm and node still return the same versions. I also tried uninstalling and reinstalling nodejs without specifying a specific version (so presumably it'd grab the latest stable?) but still the same version as before.

Is it trying to install this specific version for a reason? Why is it so far behind?

3
  • I use this to install node in all my Debian based systems - including pi - though, not sure 32bit Raspberry Pi OS is supported, but I always use 64bit Raspberry Pi OS on a pi 4 - there's also the tarballs available on nodejs itself at nodejs.org/en/download/current Jan 24 at 22:03
  • 2
    Debian is a conservative OS. Major packages do not change (except security updates) until next release, and even then is generally behind the cutting edge. If you really want the latest packages you need to install from source (and accept any incompatibilities).
    – Milliways
    Jan 24 at 22:33
  • 1
    Check out nvm to install the latest version and still keep your system version. Jan 24 at 22:47

2 Answers 2

2

This is more a suggestion than an answer - I have no need for nodejs or npm, nor do I intend to install them. IOW, this answer reflects an approach I used for an objective similar to yours.

I'd suggest you look into Stow. I used it to good effect to install an updated version of a networking utility that I used regularly. I was pleased with the result, and if you're interested, I wrote up a recipe or "how-to" guide for Stow that you may find useful. Some of the links and references in that document may also help.

As pointed out in the comments, Debian (from which RPi OS is derived) is considered to be a conservative distro, and typically stays well back from the cutting edge. That conservative policy does occasionally create the need for a current version. When you find yourself in this situation, Stow may be an efficient and effective solution.

0

As others have said, the reason its behind is because Debian is conservative like that.

To update I followed @Steve Robillard's suggestion and used nvm:

  1. Install nvm: $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
  2. Install actual latest node: $ nvm install node # "node" is an alias for the latest version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.