gpt4 book ai didi

node.js - Docker compose : npm ERR! 缺少脚本:构建

转载 作者:行者123 更新时间:2023-12-02 21:00:17 24 4
gpt4 key购买 nike

您好,我不知道在尝试将 docker compose 与 postgress 一起使用时我错在哪里

docker 撰写 yml:

version: "3.7"
services:
db:
image: postgres
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: emasa
volumes:
- ./pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
web:
image: emasapg
depends_on:
- dbs
ports:
- "4000:4000"

dockerfile
FROM node as builder
WORKDIR usr/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build


FROM node
WORKDIR usr/app
COPY package*.json ./
RUN npm install --production

COPY --from=builder /usr/app/dist ./dist

COPY ormconfig.docker.json ./ormconfig.json
COPY .env .

expose 4000
CMD node dist/src/index.js

我的 package.json:
{
"name": "back-end",
"version": "0.0.1",
"description": "Awesome project developed with TypeORM.",
"devDependencies": {
"@types/express": "^4.17.3",
"@types/graphql": "^14.5.0",
"@types/node": "^13.9.1",
"ts-node": "8.6.2",
"typescript": "3.3.3333"
},
"dependencies": {
"apollo-server-express": "^2.11.0",
"express": "^4.17.1",
"graphql": "^14.6.0",
"pg": "^7.3.0",
"reflect-metadata": "^0.1.13",
"typeorm": "0.2.24"
},
"scripts": {
"start": "ts-node src/index.ts"
}
}

呃:

npm ERR! missing script: build



我的文件结构:

enter image description here

错误从这一行开始:

line 6 : RUN npm run build



编辑 :忘记将 package.json 添加到问题中

最佳答案

它基本上是在提示缺少构建脚本,它会尝试运行它,但是在您的 package.json 中缺少它!

我认为您应该尝试更新您的package.json文件并添加构建脚本:

{
"name": "back-end",
"version": "0.0.1",
"description": "Awesome project developed with TypeORM.",
"devDependencies": {
"@types/express": "^4.17.3",
"@types/graphql": "^14.5.0",
"@types/node": "^13.9.1",
"ts-node": "8.6.2",
"typescript": "3.3.3333"
},
"dependencies": {
"apollo-server-express": "^2.11.0",
"express": "^4.17.1",
"graphql": "^14.6.0",
"pg": "^7.3.0",
"reflect-metadata": "^0.1.13",
"typeorm": "0.2.24"
},
"scripts": {
"start": "ts-node src/index.ts",
"build": "" // your build script goes here, "tsc" should be fine
}
}

关于node.js - Docker compose : npm ERR! 缺少脚本:构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60728097/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com