npm:后安装未在docker中运行 [英] npm : Postinstall not running in docker

查看:75
本文介绍了npm:后安装未在docker中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个npm软件包(npm v 5.5.1,节点版本是9.2.0)。如果我在本地计算机上运行 npm install ,则将执行package.json中定义的 postinstall ,但如果我运行相同的命令在Docker文件中执行命令 RUN npm install ,即,当命令在容器中运行时,不执行 postinstall 步骤。任何输入可能是这里的问题?

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 ?

推荐答案

尝试使用-unsafe-perm 选项。以root身份运行时,npm不会运行任何脚本。

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

或者,在Dockerfile中创建一个用户并切换到该用户:

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

FROM ...
RUN groupadd -r app && useradd -r -g app app
USER app

这篇关于npm:后安装未在docker中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆