1

I updated Node.js to 5.x, and after then I can't use npm install. Every time to use this, it causes errors:

$ npm install react-motion
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "am2"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! code EINVALIDTYPE

npm ERR! typeerror Error: Argument #1: Expected string but got object
npm ERR! typeerror     at markDeps (/usr/local/lib/node_modules/npm/lib/install/deps.js:87:5)
npm ERR! typeerror     at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:35
npm ERR! typeerror     at Array.forEach (native)
npm ERR! typeerror     at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:11
npm ERR! typeerror     at Array.forEach (native)
npm ERR! typeerror     at asyncMap (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:51:8)
npm ERR! typeerror     at Array.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
npm ERR! typeerror     at LOOP (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
npm ERR! typeerror     at chain (/usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:20:5)
npm ERR! typeerror     at recalculateMetadata (/usr/local/lib/node_modules/npm/lib/install/deps.js:112:3)
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror     <http://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!         

and npm install not working anymore, I can't go back to previous version of node!

$ sudo -i
# npm install -g n    // causes same errors!
# n 4.4.2;            // not working anymore.

Should I reinstall node.js entirely? Or can I fix it? Any advice will very appreciate.

1
  • I got following error when I try to install a package. The problem was in my package.json file and somehow it's edited one installed package name to empty string. No new package was not installing until I fixed the package.json file. npm ERR! code EINVALIDTYPE npm ERR! typeerror Error: Argument #2: Expected string but got null npm ERR! typeerror at exports.findRequirement (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:756:3) npm ERR! typeerror at computeMetadata (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:135:9) npm ERR! typeerror
    – Swapon
    Commented Oct 4, 2021 at 9:14

1 Answer 1

2

Try to clean your npm cache at first:

rm -rf ~/.npm

npm cache clear

Next step you could try to rebuild your existing packages:

npm rebuild

Also guys say, that Node version 5.1 could fix this issue:

After putting Node 5, npm ERR! code EINVALIDTYPE?

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