Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't install grpc-tools because of node-pre-gyp error #604

Closed
RyosukeCla opened this issue Oct 30, 2018 · 4 comments
Closed

Couldn't install grpc-tools because of node-pre-gyp error #604

RyosukeCla opened this issue Oct 30, 2018 · 4 comments

Comments

@RyosukeCla
Copy link

Problem description

When I install grpc-tools in docker, installation fails. and this error is shown below.

Step 2/8 : RUN npm i -g grpc-tools
 ---> Running in 5fc27f4c60f3
/usr/local/bin/grpc_tools_node_protoc -> /usr/local/lib/node_modules/grpc-tools/bin/protoc.js
/usr/local/bin/grpc_tools_node_protoc_plugin -> /usr/local/lib/node_modules/grpc-tools/bin/protoc_plugin.js
> [email protected] install /usr/local/lib/node_modules/grpc-tools
> node-pre-gyp install

node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: EPERM: operation not permitted, utime '/usr/local/lib/node_modules/grpc-tools/bin'
node-pre-gyp ERR! System Linux 4.9.125-linuxkit
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/grpc-tools/node_modules/.bin/node-pre-gyp" "install"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/grpc-tools
node-pre-gyp ERR! node -v v10.12.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.38
node-pre-gyp ERR! not ok
EPERM: operation not permitted, utime '/usr/local/lib/node_modules/grpc-tools/bin'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-10-30T20_10_13_507Z-debug.log
ERROR: Service 'node-server' failed to build: The command '/bin/sh -c npm i -g grpc-tools' returned a non-zero code: 1

This is my dockerfile.

FROM node:10.12.0

RUN npm i -g grpc-tools

RUN useradd --user-group --create-home admin

ENV HOME=/home/admin

WORKDIR $HOME/app

RUN npm config set save-prefix=''

RUN chown -R admin:admin $HOME

USER admin

I tried, but I couldn't solve this problem😭

Reproduction steps

$ docker build

Environment

@murgatroid99
Copy link
Member

When running npm under docker, you should pass the option --unsafe-perm. So, your second line should say RUN npm i -g --unsafe-perm grpc-tools.

@nicolasnoble
Copy link
Member

More specifically, when running npm as root. And by default, any RUN command from a Dockerfile runs as root.

@nicolasnoble
Copy link
Member

This Dockerfile works:

FROM node:10.12.0

RUN npm i -g grpc-tools --unsafe-perm
RUN useradd --user-group --create-home admin
ENV HOME=/home/admin
WORKDIR $HOME/app
RUN npm config set save-prefix=''
RUN chown -R admin:admin $HOME
USER admin

@RyosukeCla
Copy link
Author

@murgatroid99 @nicolasnoble

thank you for your quick help!!
it works!!!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants