How do I install NPM on a Chromebook?

Viewed 2084

I installed NodeJS (via Linux terminal) but it doesn't seem to come bundled with NPM:

:~$ sudo apt-get install -y nodejs
:~$ node -v
:~$ v10.23.1
:~$ npm -v
:~$ -bash: npm: command not found

I have an Acer Chromebook R 13 with an ARM processor.

3 Answers

Installing NodeJs

sudo apt-get install curl gnupg -y
curl -sl https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install -y nodejs

In my case I didn't have the install script for npm, so got it externally

curl -L https://npmjs.org/install.sh | sudo sh

Due to trying to answer in comments i will attempt to give a complete answer here.

You need to first aquire the correct package for your architecture. As you have noted you are using the Acer Chromebook R13. This uses the MediaTek MT8173C processsor which utilizes ARMv8 instruction set.

following these commands should get you up and running.

#first, download the proper package for your architecture
mkdir myNodeJS
cd myNodeJS
wget https://nodejs.org/dist/v14.15.5/node-v14.15.5-linux-arm64.tar.xz
tar -xf node-v14.15.5-linux-arm64.tar.xz
cd node-v14.15.5-linux-arm64
cd bin
sudo cp node /usr/local/bin
cd ..
cd /lib/node_modules/npm/scripts
./install.sh

That should be it, if you have problems, you can resort to the first link that i sent for install instructions

nvm is recommended on the npmjs.com install page, and nvm has installation instructions of using an install script.

  1. Open the Terminal app on Chromebook.
  2. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  3. nvm install node
  4. npm is now ready.
Related