node.js - Docker 与 Node.js 和 Express.js

标签 node.js express docker

我正在尝试将 docker 与我的 Node 应用程序一起使用,我的 Dockerfile 如下所示:

RUN     apt-get update
RUN     apt-get -y install build-essential
RUN     apt-get install -y nodejs
RUN     apt-get install -y npm

ADD     . /src
RUN     cd /src && npm install

EXPOSE  8080

CMD     ["node","/src/app.js"]

但是在尝试安装https://registry.npmjs.org/wordwrap/-/wordwrap-后运行npm install时运行docker build 0.0.2.tgz 我收到错误:

The command 'bin/sh -c /src && npm install' returned a non-zero code : 1

什么会导致这样的问题?我已经尝试安装node-legacy而不是node,但它不起作用

最佳答案

试试这个:

# put this line on your code (if you are using ubuntu)
# this make a link from nodejs to node to add compatibility on ubuntu OS
RUN ln -s /usr/bin/nodejs /usr/bin/node

# set your current directory with WORKDIR
WORKDIR /src
RUN sudo npm install

关于node.js - Docker 与 Node.js 和 Express.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32995774/

相关文章:

node.js - Node 异常处理

node.js - 如何将实体添加到仅与 ID 相关的关系而不获取它?

python - 找不到部署在docker+nginx+uwsgi下的flask应用程序的模块

Docker-compose 容器端口不起作用

node.js - Nodejs Passport 认证挂了

javascript - 带有 firebase 的 Node.js 不会在 session 中保存信息

javascript - 如何从NodeJS中的静态页面访问index.js

node.js - 使用 SailsJS/Express 在请求之间将对象保存在内存中

javascript - 处理快速异步中间件中的错误

docker - 命令 '/bin/sh -c apt-get install erlang'返回了非零代码:1