【发布时间】:2020-05-18 02:05:15
【问题描述】:
我创建了一个 index.js、index.html 和 package.json 文件,我想添加 express。当我在终端中编写“npm install express”时,出现以下错误。到目前为止,我尝试了“sudo npm install -g express”,完全删除节点和 npm 并重新安装。我还在这里解决了其他问题,但没有一个对我有用。无论我用 npm 写什么,我都会遇到同样的错误。 (我使用的是 macOS)
你有什么建议吗?
这是我得到的错误:
Error: EROFS: read-only file system, mkdir '/npm'
TypeError: Cannot read property 'loaded' of undefined
at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:97: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:78: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:81:7
at Array.forEach (<anonymous>)
at /usr/local/lib/node_modules/npm/lib/config/core.js:80: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:171:20)
/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:97
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:97:27)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:216:3)
at process.emit (events.js:223:5)
at process._fatalException (internal/process/execution.js:150:25)
【问题讨论】:
标签: node.js npm permissions