NPM 错误:错误:EROFS:只读文件系统,mkdir '/npm' [英] NPM Error : Error: EROFS: read-only file system, mkdir '/npm'

查看:961
本文介绍了NPM 错误:错误:EROFS:只读文件系统,mkdir '/npm'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 index.js、index.html 和 package.json 文件,我想添加 express.当我在终端中编写npm install express"时,出现以下错误.到目前为止,我尝试了sudo npm install -g express",完全删除节点和 npm 并重新安装.我还在这里解决了其他问题,但没有一个对我有用.无论我用 npm 写什么,我都会遇到同样的错误.(我使用的是 macOS)

I created an index.js, index.html and package.json file and I wanted to add express. When I write 'npm install express' in the terminal, I'm getting the error below. So far, I tried 'sudo npm install -g express', deleting node and npm completely and re-install. I also went through other questions over here but none of them worked out for me. Whatever I write with npm I get the same error. (I'm using 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)

推荐答案

该错误表示您无权在路径 /npm 处安装任何带有 npm 的东西.
要验证此运行 npm root -g.这应该返回 /npm.

The error means that you have no permission to install anything with npm at the path /npm.
To verify this run npm root -g. This should return /npm.

请注意,/npm 不是 MacOS 上的默认安装路径(请参阅 https://stackoverflow.com/a/35638528/1754076).

Note that /npm ist not the default installation path on MacOS (see https://stackoverflow.com/a/35638528/1754076).

检查您的 npm 配置文件并将默认安装路径更改为您有写访问权限的位置.您也可以使用 npm 本身更改默认安装路径.

Checkout your npm configuration file and change the default installation path to something where you do have write access. You can also use npm itself to change the default installation path.

这篇关于NPM 错误:错误:EROFS:只读文件系统,mkdir '/npm'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆