[英]NodeJS Docker container build failing - npm ERR! code EAccess
[英]Docker Container npm ERR! Internal watch failed: Circular symlink detected
我創建了一個快速 API 並且它會在端口 5000 上正常運行。當我將它放在 Docker 容器上時,它首先運行但隨后我收到這樣的錯誤消息。
> nodejs-express-sequelize-postgresql@1.0.0 start
> nodemon server.js
[nodemon] 2.0.6
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
(node:33) [SEQUELIZE0004] DeprecationWarning: A boolean value was passed to options.operatorsAliases. This is a no-op with v5 and should be removed.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:33) Warning: Accessing non-existent property 'Sequelize' of module exports inside circular dependency
Server is running on port 5000.
Executing (default): CREATE TABLE IF NOT EXISTS "simplenims" ("id" SERIAL , "nim" VARCHAR(255), "nama" VARCHAR(255), "status" BOOLEAN, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id"));
[nodemon] Internal watch failed: Circular symlink detected: "/usr/bin/X11" points to "/usr/bin"
npm ERR! code 1
npm ERR! path /
npm ERR! command failed
npm ERR! command sh -c nodemon server.js
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-12-14T11_53_26_130Z-debug.log
這是我的 Dockerfile 看起來像
FROM node:latest
WORKDIR /
COPY package*.json ./
RUN npm install
COPY . .
ENV port=5000
EXPOSE 5000
CMD ["npm", "start"]
我按照 Docker 的文檔制作了 Dockerfile。 有什么問題或者我需要添加 Dockcerfile 嗎?
Nodemon 監視項目根目錄中的所有文件。 為避免此問題,您可以在項目根目錄中創建nodemon.js
文件,其內容如下:
{
"ext": "js"
}
這個答案來自 Github 問題。 這與您的問題非常相似。
這與nodemon有關。 解決方法如下——
使用 dockerfile 像這樣:
FROM node:14.15.0
WORKDIR /app
COPY . /app
RUN npm install
CMD npm run dev
構建映像,然后在具有交互式終端(可選)的容器中運行它,將卷從當前主機目錄(pwd)掛載到容器中的 WORKDIR(/app):
docker build -t imagename:tag .
docker run -it -p 1234:1234 -v $(pwd):/app imagename:tag
或者,使用 docker-compose.yml
version: '3.6'
services:
server:
build: .
volumes:
- .:/app
ports:
- "3000:3000"
然后運行
docker-compose up --build
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.