npm项目的

时间:2017-08-22 04:57:00

标签: node.js docker npm docker-compose

我正在尝试为crates.io项目添加docker-compose设置。 npm文件的当前文件如下:

FROM node:8.4
ENV npm_config_global true
COPY package.json package-lock.json ./
RUN npm install

它一切都很好但是当我尝试构建它时,它所做的只是:

Building frontend
Step 1/4 : FROM node:8.4
 ---> 6f6ffe2a1302
Step 2/4 : ENV npm_config_global true
 ---> Using cache
 ---> 868e1aec7aac
Step 3/4 : COPY package.json ./
 ---> 3846f64854e0
Removing intermediate container a1dea9f3f3a2
Step 4/4 : RUN npm install
 ---> Running in 18b3f1003133
npm info it worked if it ends with ok
npm info using npm@5.3.0
npm info using node@v8.4.0
npm info lifecycle cargo@0.0.0~preinstall: cargo@0.0.0
npm info linkStuff cargo@0.0.0
npm info lifecycle cargo@0.0.0~install: cargo@0.0.0
npm info lifecycle cargo@0.0.0~postinstall: cargo@0.0.0
+ cargo@0.0.0
added 1 package in 0.23s
npm info ok 
 ---> 6785fa0a2b21
Removing intermediate container 18b3f1003133
Successfully built 6785fa0a2b21
Successfully tagged cratesio_frontend:latest

因此根本没有安装任何devDependencies。我在这里错过了什么?我应该添加一些其他参数吗?

我已经尝试使用--only=dev运行它并且它也无法正常运行。

在不复制package-lock.json的情况下运行它也会导致同样的事情:

Building frontend
Step 1/4 : FROM node:8.4
 ---> 6f6ffe2a1302
Step 2/4 : ENV npm_config_global true
 ---> Running in b77c06987f48
 ---> f52a6255ea31
Removing intermediate container b77c06987f48
Step 3/4 : COPY package.json ./
 ---> 26f4c713399a
Removing intermediate container 27d6fe45b3be
Step 4/4 : RUN npm install
 ---> Running in 58d4bd0e8f75
npm info it worked if it ends with ok
npm info using npm@5.3.0
npm info using node@v8.4.0
npm info lifecycle cargo@0.0.0~preinstall: cargo@0.0.0
npm info linkStuff cargo@0.0.0
npm info lifecycle cargo@0.0.0~install: cargo@0.0.0
npm info lifecycle cargo@0.0.0~postinstall: cargo@0.0.0
+ cargo@0.0.0
added 1 package in 0.207s
npm info ok 
 ---> 39f68ccde408
Removing intermediate container 58d4bd0e8f75
Successfully built 39f68ccde408
Successfully tagged cratesio_frontend:latest

1 个答案:

答案 0 :(得分:0)

  1. 检查package-lock.jsonpackage.json文件的devDependency。正如我从日志文件中看到的那样,您将cargo包安装为devDependency。

  2. 您的Dockerfile和日志相互矛盾。请检查在构建期间使用的Dockerfile。

  3. 详细信息Dockerfile:

    • Dockerfile中的第4行是RUN npm install
    • Dockerfile中的第5行不存在。

    详情日志:

    Step 4/5 : RUN npm install --only=dev
    ...
    Step 5/5 : RUN npm install
    ...