Search code examples
node.jsdockerdocker-composepermissionsnpm-install

`npm install` error when installing in docker container permissions error


I've got a weird error that happens on my new laptop but not on my old one (new: M1 ARM Mac, old: Intel Mac).

I mount my code as a volume in docker-compose and would bring the container up and just npm install and everything would install correctly. node_modules would get created in the volume and I could run. On the new Mac, it throws a permissions error.

Docker-compose volume mount:

volumes:
- ./:/app/

What's weird about these is that I can go in to the directories that it's complaining about, while in the docker container, and create/view files.

  • Node Version: 10.24.0
  • NPM Version: 5.8.0

First Error:

glob error { [Error: EPERM: operation not permitted, scandir '/app/node_modules/signal-exit']node_modules/shallowequal
  errno: -1,
  code: 'EPERM',
  syscall: 'scandir',
  path: '/app/node_modules/signal-exit' }

Second Error

npm ERR! Error: EPERM: operation not permitted, open '/app/node_modules/set-value/package.json.1296712643'
npm ERR!  { [Error: EPERM: operation not permitted, open '/app/node_modules/set-value/package.json.1296712643']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, open '/app/node_modules/set-value/package.json.1296712643'
npm ERR!      errno: -1,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'open',
npm ERR!      path: '/app/node_modules/set-value/package.json.1296712643' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, open \'/app/node_modules/set-value/package.json.1296712643\'',
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: '/app/node_modules/set-value/package.json.1296712643',
npm ERR!   parent: 'capella' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user

Any suggestions on what to do next would be appreciated.


Solution

  • I found the answer. I was using colima to run my docker containers on the new laptop while on the old one I was using docker desktop. I switched back and everything started working again.