0

I've a lot of Raspberry Pi clients, which I've initialized with a 4.5.0 Node JS version, using the following lines of code:

wget https://nodejs.org/dist/v4.5.0/node-v4.5.0-linux-armv7l.tar.gz
tar -xvf node-v4.5.0-linux-armv7l.tar.gz
cd node-v4.5.0-linux-armv7l
cp -R * /usr/local/

// This copies the following files:
// bin  CHANGELOG.md  include  lib  LICENSE  README.md  share

Times changed and I noticed that meanwhile you install and manage Node using these lines of code:

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

// Do other stuff like rebuilding, etc.

I'd like to update all clients deploying a script, which leads us to my point. When I execute the update on my Test-Pi node -v returns v4.5.0 anyways, I think due to the fact that the old version is still located in /usr/local/.

I'd like to know, what's the best solution to update Node in my case and to be able to update / manage Node better in the future? Just remove node / npm files from the folders and run the update script?

user3191334
  • 305
  • 1
  • 7
  • 15

2 Answers2

1

I recommend you to tryout NVM (node version manager).

It allows you to install Node.js and global node packages in your user space and easyly install different versions and switch between them with ease.

The documentation is a bit owerwhelming at first but it gets all down to:

  • curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
  • logout and login back again
  • nvm install node 8 (or any version you like)
  • done

Upgrading to a new version is a nvm install node 8.6 or whatever the new version is.

Switching to another version is something like nvm use node 4.

All is saved in ~/.nvm so it does not pollute your system and can be easily removed.

kwasmich
  • 2,702
  • 15
  • 22
0

Another install method?

Example:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

After that:

apt-get install nodejs -y
node -v
npm -v

Hope it helps

read more