6

I installed node and npm on Ubuntu 14.04 and when I try to use any npm command, I get the following error:

/usr/local/lib/node_modules/npm/lib/config/cmd-list.js:113
module.exports.aliases = Object.assign({}, shorthands, affordances)
                            ^
TypeError: Object function Object() { [native code] } has no method 'assign'
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/cmd-list.js:113:33)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /usr/local/lib/node_modules/npm/lib/npm.js:37:17
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/npm.js:471:3)
at Module._compile (module.js:456:26)

I'm new to using node and I didn't find any solution to such an error online

4
  • 1
    What was an exact command line you tried? Are you using sudo? Commented Jul 8, 2017 at 16:57
  • 1
    @R.Richards I agree we need the exact command, but i don't think it's related to sudo otherwise it would be EACESS error Commented Jul 8, 2017 at 16:58
  • You are right! We would be seeing that in the output. Good catch. Commented Jul 8, 2017 at 16:59
  • Im trying to install angular with npm using npm install angular command, even with sudo this isnt working. I already tried reinstalling node and npm once. Commented Jul 8, 2017 at 17:00

4 Answers 4

32

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

Sign up to request clarification or add additional context in comments.

1 Comment

Is the deb link still valid for today?
5

This worked for me on Ubuntu 18.04:

sudo apt install nodejs
sudo apt install npm

Comments

1

npm might be older version,

so remove nodejs,

sudo apt-get remove nodejs
sudo apt-get remove npm

then,

sudo apt-get install curl #if you dont have curl

Node.js v6:

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

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

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

for more info, package manager

Comments

0

Hi, You can try this one also. This worked for me :)

#optional

sudo apt-get update

#install curl (optional)

sudo apt-get install build-essential libssl-dev curl

#install curl node package

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

#Install node

sudo apt-get install -y nodejs

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.