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)
Do you have any suggestions?
This is the error I am getting:
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)
Bug description
All commands except yarn -v
give the error An unexpected error occurred: "EROFS: read-only file system, mkdir '/cache'".
Command
What is the current behavior?
What is the expected behavior?
installing packages and running properly.
Steps to Reproduce
- yarn
Environment
- Node Version:
12.17.0
- Yarn v1 Version:
1.22.4
- OS and version: macOS Catalina 10.15.6
Arguments:
/usr/local/Cellar/node@12/12.18.3/bin/node /usr/local/Cellar/yarn/1.22.4/libexec/bin/yarn.js
PATH:
/usr/local/opt/node@12/bin:/usr/local/opt/node@12/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
Yarn version:
1.22.4
Node version:
12.18.3
Platform:
darwin x64
Trace:
Error: EROFS: read-only file system, mkdir '/cache'
npm manifest:
No manifest
yarn manifest:
No manifest
Lockfile:
No lockfile
I think this is related with node version.
@tolgacesur
Hey there.
Same issue here.
Yarn version:
1.22.10
Node version:
15.10.0
Platform:
darwin x64
EROFS: read-only file system, mkdir '/npm-packages-offline-cache'
Could you plz share how did u solve this problem ?
Thx.
hi @leizhilong
I uninstalled yarn and node. I install node and yarn with different version and solved this problem. I think this is a compatibility issue of yarn and node versions
hi, @tolgacesur
Thanks for the reply.
I tried reinstalling yarn with homebrew and npm, but nothing worked, which is pretty odd.
I’ll try your way.
Thanks again.
update:
by removing a stupid line in ~/.yarnrc
which misconfigured yarn to use /npm-packages-offline-cache
as local cache directory, I finally solved this problem.
Nothing to do with yarn itself, just another mistake.
yarnpkg
locked as resolved and limited conversation to collaborators
Mar 10, 2021
Hi everyone!
I wanted to ask about an error which I have encountered. It has to something with file system being only read — only. I have shared the error below. Anyone kind of help will be highly appreciated.
npm ERR! Linux 3.10.0-514.26.2.el7.ve.x86_64
npm ERR! argv «/usr/bin/node» «/usr/bin/.npm__» «install» «-g» «feo» «—save»
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! path /usr/lib/node_modules
npm ERR! code EROFS
npm ERR! errno -30
npm ERR! syscall access
npm ERR! rofs EROFS: read-only file system, access ‘/usr/lib/node_modules’
npm ERR! rofs This is most likely not a problem with npm itself
npm ERR! rofs and is related to the file system being read-only.
npm ERR! rofs
npm ERR! rofs Often virtualized file systems, or other file systems
npm ERR! rofs that don’t support symlinks, give this error.
npm ERR! Please include the following file with any support request:
npm ERR! /var/ilx/workspaces/Common/ilxws_Demo/extensions/ilxex_Demo/npm-debug.log
I have a rw file system /myraid0
.
# cat /proc/mounts | grep myraid0
/dev/mapper/isw_cfdbejjgdi_myraid0p1 /myraid0 ext4 rw,relatime,stripe=8,data=ordered 0 0
I have no problem writing to /myraid0
as any user.
redis@host:~$ echo hi > /myraid0/tmp/redis/test
redis@host:~$ cat /myraid0/tmp/redis/test
hi
However, my process can’t write a file on /myraid0
, due to EROFS
(Read-only file system).
open("temp-4036.rdb", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 EROFS (Read-only file system)
This shows the process views the mount as ro.
# cat /proc/15920/mounts | grep myraid0
/dev/mapper/isw_cfdbejjgdi_myraid0p1 /myraid0 ext4 ro,relatime,stripe=8,data=ordered 0 0
Why does the process only have read only view of the mount?
Thanks!
Additional details
- Ubuntu 16.04
Linux jeff-apartment-2015 4.4.0-36-generic #55-Ubuntu SMP Thu Aug 11 18:01:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
- App is
redis-server
. It’s failing to save the snapshots to a non-root device - Redis error is
Failed opening .rdb for saving: Read-only file system
- Installed version 3.0.6 via
apt-get
- Launched by
systemd
- Listing of
/proc/15920/ns
(requested by @VenkatC):
lrwxrwxrwx 1 redis redis 0 Sep 16 05:39 cgroup -> cgroup:[4026531835]
lrwxrwxrwx 1 redis redis 0 Sep 15 18:03 ipc -> ipc:[4026531839]
lrwxrwxrwx 1 redis redis 0 Sep 15 18:03 mnt -> mnt:[4026532343]
lrwxrwxrwx 1 redis redis 0 Sep 15 18:03 net -> net:[4026531957]
lrwxrwxrwx 1 redis redis 0 Sep 15 18:03 pid -> pid:[4026531836]
lrwxrwxrwx 1 redis redis 0 Sep 15 18:03 user -> user:[4026531837]
lrwxrwxrwx 1 redis redis 0 Sep 15 18:03 uts -> uts:[4026531838]
apparmor_status | grep redis
returns nothing (requested by @Gilles)- Nothing else in the logs more informative than the strace output.
Process namespaces
Working bash shell for redis user
ls -l /proc/7359/ns/mnt
lrwxrwxrwx 1 redis redis 0 Sep 15 18:03 /proc/7359/ns/mnt -> mnt:[4026531840]
Not working redis process
ls -l /proc/15920/ns/mnt
lrwxrwxrwx 1 redis redis 0 Sep 15 18:03 /proc/15920/ns/mnt -> mnt:[4026532343]
Working bash shell for my user
ls -atlrh /proc/7138/ns/mnt
lrwxrwxrwx 1 jeff jeff 0 Sep 15 18:03 /proc/7138/ns/mnt -> mnt:[4026531840]