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
我在没有sudo的情况下启动npm i时出现此错误。使用sudo它工作正常。我修复了所有权限,安装了没有sudo的节点,但错误仍然存在。
node -v
v8.11.2
npm -v
5.6.0
EDIT1: 以下是日志文件的最后几行:
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:我重新安装了节点并按照指南进行操作,现在我遇到了一个不同的错误:
Unhandled rejection Error: invalid config key requested: singleuffer@5.1.2 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
答案 0 :(得分:1)
这绝对是文件夹权限问题。有多种方法可以解决这个问题,本文将对此进行详细说明。
答案 1 :(得分:0)
对于Debian发行版,以下内容应使您无需使用sudo即可运行npm install
。
将npm前缀更改为用户有权写入的位置
npm config set prefix=$HOME/david/
然后运行以下命令并将其添加到.bashrc
export PATH=$HOME/david/bin:$PATH
获得/ usr / local的所有权
sudo chown -R $USER /usr/local
信用去here