昨天我在Windows 10 Pro上将Docker更新为版本Docker version 19.03.5, build 633a0ea
。
所有项目均正常运行,并且未进行任何其他配置。
.dockerignore
node_modules
npm-debug.log
.gitignore
.env
docker-compose.yml
version: '3.7'
services:
backend:
build:
context: .
volumes:
- .:/usr/src/app
- node_modules:/usr/src/app/node_modules
- .git:/usr/src/app/.git
ports:
- '5000:5000'
- '9229:9229'
links:
- mongo
environment:
- CHOKIDAR_USEPOLLING=true
mongo:
image: mongo
ports:
- '27017:27017'
volumes:
node_modules:
Dockerfile
FROM node:10
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 5000
CMD npm run server
执行docker-compose up --build
后,出现以下错误:
backend_1 | > nodemon server.js
backend_1 |
backend_1 | sh: 1: nodemon: not found
backend_1 | npm ERR! code ELIFECYCLE
backend_1 | npm ERR! syscall spawn
backend_1 | npm ERR! file sh
backend_1 | npm ERR! errno ENOENT
backend_1 | npm ERR! project-api@1.0.1 server: `nodemon server.js`
backend_1 | npm ERR! spawn ENOENT
backend_1 | npm ERR!
backend_1 | npm ERR! Failed at the project-api@1.0.1 server script.
backend_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
backend_1 |
backend_1 | npm ERR! A complete log of this run can be found in:
backend_1 | npm ERR! /root/.npm/_logs/2020-01-23T04_11_11_071Z-debug.log
我的文件夹结构如下:
root
| client
| .dockerignore
| docker-compose.yml
| Dockerfile
| package-lock.json
| package.json
...
| .dockerignore
| docker-compose.yml
| Dockerfile
| package-lock.json
| package.json
| server.js
如您所见,我内部还有另一个项目,它正在按预期运行。
答案 0 :(得分:0)
使用来自package.json
文件夹的本地nodemon路径更新node_modules
。
喜欢:
./node_modules/nodemon/bin/nodemon.js server.js