如何在Dockerfile中为全局包设置自定义npm目录?

时间:2018-01-31 11:52:40

标签: node.js docker npm dockerfile

我刚刚阅读了有关Global npm dependencies的最佳做法,并尝试在我的Dockerfile中使用此方法:

FROM node:carbon
...
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH="/home/node/.npm-global:${PATH}"
...
RUN npm install -g nodemon
...
CMD ["nodemon", "server.js"]
USER node

但是当我尝试启动容器时,我得到了:

ERROR: for my_project_node_1  Cannot start service my_project_node:
OCI runtime create failed: container_linux.go:296: 
starting container process caused "exec: \"nodemon\": 
executable file not found in $PATH": unknown

ERROR: for my_project_node  Cannot start service my_project_node: 
OCI runtime create failed: container_linux.go:296: 
starting container process caused "exec: \"nodemon\": 
executable file not found in $PATH": unknown

我只是不明白我做错了什么..

如何在我从这里https://stackoverflow.com/a/38742545/202550

获取的Dockerfile中设置PATH环境变量

0 个答案:

没有答案