os-js/OS.js

NPM Permission error in docker-compose up

mahsashadi opened this issue · 12 comments

Hi

I need to run OS.js with docker-compose up, but I get the following npm error :
npm ERR! Error: EACCES: permission denied, access '/usr/src/osjs/node_modules'

I checked the /usr/src/osjs directory in osjs container. I think it must be owned by node user, but it doesn't!

This is probably because you're run the npm command outside the docker context. Remove the node_modules and try again.

And then always run docker-compose exec osjs npm <command> to avoid this problem in the future.

I'm closing this because I'm pretty sure my previous comment is the solution.

Re-open if I'm wrong :D

Unfortunately it didn't work!
I try removing node_modules.
I also try removing previous image and container to make new ones.
I get the following error:

Attaching to osjs_osjs_1
osjs_1  | npm WARN checkPermissions Missing write access to /usr/src/osjs
osjs_1  | npm ERR! code EACCES
osjs_1  | npm ERR! syscall access
osjs_1  | npm ERR! path /usr/src/osjs
osjs_1  | npm ERR! errno -13
osjs_1  | npm ERR! Error: EACCES: permission denied, access '/usr/src/osjs'
osjs_1  | npm ERR!  { [Error: EACCES: permission denied, access '/usr/src/osjs']
osjs_1  | npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/src/osjs\'',
osjs_1  | npm ERR!   errno: -13,
osjs_1  | npm ERR!   code: 'EACCES',
osjs_1  | npm ERR!   syscall: 'access',
osjs_1  | npm ERR!   path: '/usr/src/osjs' }
osjs_1  | npm ERR! 
osjs_1  | npm ERR! The operation was rejected by your operating system.
osjs_1  | npm ERR! It is likely you do not have the permissions to access this file as the current user
osjs_1  | npm ERR! 
osjs_1  | npm ERR! If you believe this might be a permissions issue, please double-check the
osjs_1  | npm ERR! permissions of the file and its containing directories, or try running
osjs_1  | npm ERR! the command again as root/Administrator.
osjs_1  | 
osjs_1  | npm ERR! A complete log of this run can be found in:
osjs_1  | npm ERR!     /home/node/.npm/_logs/2021-01-30T11_08_25_416Z-debug.log
osjs_1  | 
osjs_1  | > @osjs/osjs@3.1.11 build /usr/src/osjs
osjs_1  | > webpack
osjs_1  | 
osjs_1  | sh: 1: webpack: not found

Can you share your file ?

Also, are you on Windows by chance ?

Wich file you mean?
I use docker-compose up right after cloning the source code, i.e. after below commands:

git clone -b master --single-branch https://github.com/os-js/OS.js.git
cd OS.js

No, I am on linux ubuntu 18.04

I use docker-compose up right after cloning the source code, i.e. after below commands:

OK.

I can't reproduce this on any of my [Linux] systems 🤔

Where are you trying to run this on your filesystem, and what user are you doing it as ?

I clone the source code somewhere in my home directory (as what I did previously for running osjs locally)
I try the command with root (and also non-root) user

I just realized that I've set the user in the docker-compose file explicitly:

https://github.com/os-js/OS.js/blob/master/docker-compose.yml#L37

This might be what actually causes the issues as it will use 1000:1000 for the permissions.

Remove that line and try again.

Removing that line works.

How is it recommended to npm install in my own developed packages?
for example in src/client/my-widget

docker-compose exec osjs npm install src/client/my-widget.