NPM 问题汇总

1. Error: setuid user id does not exist

Error: setuid user id does not exist
    at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:49:16
    at ChildProcess.exithandler (child_process.js:285:7)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Socket.stream.socket.on (internal/child_process.js:381:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:610:12)
TypeError: Cannot read property 'loaded' of undefined
    at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:98:27)
    at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:216:3)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:77:20
    at cb (/usr/local/lib/node_modules/npm/lib/npm.js:225:22)
    at /usr/local/lib/node_modules/npm/lib/npm.js:263:24
    at /usr/local/lib/node_modules/npm/lib/config/core.js:83:7
    at Array.forEach ()
    at /usr/local/lib/node_modules/npm/lib/config/core.js:82:13
    at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
    at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:173:20)
/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:98
  var doExit = npm.config.loaded ? npm.config.get('_exit') : true
                          ^

TypeError: Cannot read property 'loaded' of undefined
    at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:98:27)
    at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:216:3)
    at process.emit (events.js:182:13)
    at process._fatalException (internal/bootstrap/node.js:494:27)

在编辑器中打开以下文件:
/usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js
到 11 行,将 uidSupport = process.getuid && process.setuid 修改为 uidSupport = false

NPM 问题汇总_第1张图片

通过 npm link 可以很容易的调试开发库,有几个需要注意的地方:

  • 目录地址,看一下要链接的地址是不是正确
  • Mac 上需要使用 sudo

设置代理

$ npm config set proxy=http://127.0.0.1:8087
$ npm config delete proxy
$ npm config set registry=http://registry.npmjs.org

你可能感兴趣的:(NPM 问题汇总)