daviedave
daviedave

Reputation: 1

npm install only working when used with sudo

npm ERR! code E400
npm ERR! 400 Bad Request: typescript@https://registry.npmjs.org/typescript/-/typescript-2.6.2.tgz

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/david/.npm/_logs/2018-06-01T08_01_21_010Z-debug.log

I get this Error when I start npm i without sudo. With sudo it works fine. I fixed all the permissions, installed node without sudo, but the error still occurs.

node -v
v8.11.2

npm -v
5.6.0

Edit1: Here are the last lines of the logfile:

9991 verbose stack Error: 400 Bad Request: typescript@https://registry.npmjs.org/typescript/-/typescript-2.6.2.tgz
9991 verbose stack     at fetch.then.res (/usr/lib64/node_modules/npm8/node_modules/pacote/lib/fetchers/registry/fetch.js:42:19)
9991 verbose stack     at tryCatcher (/usr/lib64/node_modules/npm8/node_modules/bluebird/js/release/util.js:16:23)
9991 verbose stack     at Promise._settlePromiseFromHandler (/usr/lib64/node_modules/npm8/node_modules/bluebird/js/release/promise.js:512:31)
9991 verbose stack     at Promise._settlePromise (/usr/lib64/node_modules/npm8/node_modules/bluebird/js/release/promise.js:569:18)
9991 verbose stack     at Promise._settlePromise0 (/usr/lib64/node_modules/npm8/node_modules/bluebird/js/release/promise.js:614:10)
9991 verbose stack     at Promise._settlePromises (/usr/lib64/node_modules/npm8/node_modules/bluebird/js/release/promise.js:693:18)
9991 verbose stack     at Async._drainQueue (/usr/lib64/node_modules/npm8/node_modules/bluebird/js/release/async.js:133:16)
9991 verbose stack     at Async._drainQueues (/usr/lib64/node_modules/npm8/node_modules/bluebird/js/release/async.js:143:10)
9991 verbose stack     at Immediate.Async.drainQueues (/usr/lib64/node_modules/npm8/node_modules/bluebird/js/release/async.js:17:14)
9991 verbose stack     at runCallback (timers.js:810:20)
9991 verbose stack     at tryOnImmediate (timers.js:768:5)
9991 verbose stack     at processImmediate [as _immediateCallback] (timers.js:745:5)
9992 verbose cwd /home/david/Dev/Projects/MobileInfoApp/LHMobileApp
9993 verbose Linux 4.16.12-1-default
9994 verbose argv "/usr/bin/node8" "/usr/bin/npm-default" "i"
9995 verbose node v8.11.2
9996 verbose npm  v5.6.0
9997 error code E400
9998 error 400 Bad Request: typescript@https://registry.npmjs.org/typescript/-/typescript-2.6.2.tgz
9999 verbose exit [ 1, true ]

Edit2: I reinstalled node again and followed a guide, I get a diffrent error now:

Unhandled rejection Error: invalid config key requested: [email protected] extracted to /home/david/Dev/Projects/MobileInfoApp/LHMobileApp/n
    at pudGet (/usr/local/lib/node_modules/npm/node_modules/figgy-pudding/index.js:31:11)
    at FiggyPudding.get (/usr/local/lib/node_modules/npm/node_modules/figgy-pudding/index.js:13:12)
    at Object.get (/usr/local/lib/node_modules/npm/node_modules/figgy-pudding/index.js:71:16)
    at _parse (/usr/local/lib/node_modules/npm/node_modules/ssri/index.js:138:12)
    at parse (/usr/local/lib/node_modules/npm/node_modules/ssri/index.js:125:12)
    at Object.checkData (/usr/local/lib/node_modules/npm/node_modules/ssri/index.js:216:9)
    at write (/usr/local/lib/node_modules/npm/node_modules/cacache/lib/content/write.js:34:31)
    at putData (/usr/local/lib/node_modules/npm/node_modules/cacache/put.js:25:10)
    at Object.x.put (/usr/local/lib/node_modules/npm/node_modules/cacache/locales/en.js:28:37)
    at readFileAsync.then.data (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/file.js:38:28)
    at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:638:18)

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/david/.npm/_logs/2018-06-04T07_53_53_015Z-debug.log

Upvotes: 0

Views: 913

Answers (2)

nPcomp
nPcomp

Reputation: 9833

For Debian Distros, following should let you run npm install without sudo.

Change your npm prefix to somewhere that your user has permission to write to

npm config set prefix=$HOME/david/

Then run the following and add it to .bashrc

export PATH=$HOME/david/bin:$PATH

Take ownership of /usr/local

sudo chown -R $USER /usr/local

Credit goes here

Upvotes: 0

Jacob Nelson
Jacob Nelson

Reputation: 2466

This is definitely folder permission issue. There are multiple ways for solving this, which is explained in detail in this article.

Installing global node modules (Linux and Mac)

Upvotes: 1

Related Questions