Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm : Postinstall not running in docker

I have a npm package (npm v 5.5.1 and node version is 9.2.0). If i run npm install on local machine then the postinstall defined in package.json is executed but if I run the same command RUN npm install in a Docker file i.e. when the command is run inside the container then the postinstall step is not executed. Any inputs what could be the issue here ?

like image 466
user2608576 Avatar asked Dec 11 '17 07:12

user2608576


2 Answers

Try running install with --unsafe-perm option. When running as root, npm won't run any scripts.

Alternatively, create a user in the Dockerfile and switch to that user:

FROM ...
RUN groupadd -r app && useradd -r -g app app
USER app
like image 194
yamenk Avatar answered Sep 20 '22 17:09

yamenk


Another option to the selected answer: You could add this line to your dockerfile to configure your npm config inside the container (thus then allowing the execution of the postinstall script):

FROM ...
RUN npm config set unsafe-perm true
like image 44
sab Avatar answered Sep 21 '22 17:09

sab