npm command not working on ubuntu

You are most likely running an old version of node.js (verify with node -v, at the time of writing this, the latest lts is 6.x). I suppose you tried to install it with apt-get install nodejs or similar. The packages shipped with ubuntu 14 are outdated, follow the advice on nodejs' download page instead, and do the following:

Step 1, remove the old packages:

sudo apt-get remove --purge nodejs

Step 2, type the following commands one after the other and follow the screen:

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

Now you have a version of nodejs installed that allows ES6 methods, as Object.assign is one of them


This worked for me on Ubuntu 18.04:

sudo apt install nodejs
sudo apt install npm