无法在MAC终端中运行NPM

时间:2019-04-29 05:41:07

标签: npm

无法在Mac中运行npm,请尝试将其卸载再重新安装。 (已正确删除NPM,然后重新安装)。但是每次我都低于错误。

Error: EEXIST: file already exists, mkdir '/usr/local/bin/npm'
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 (<anonymous>)
    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:196:13)
    at process._fatalException (internal/process/execution.js:146:25)

当我键入NPM时,它应该运行,而不是出现错误。

1 个答案:

答案 0 :(得分:0)

它似乎与用户权限有关。请参阅这篇文章:npm error on every command: EEXIST: file already exists, mkdir 'c:\users\user\appdata\Roaming\npm'。您是否以root用户身份运行npm命令?