gpt4 book ai didi

javascript - docker ,nodejs : node not found error

转载 作者:行者123 更新时间:2023-12-03 03:26:01 24 4
gpt4 key购买 nike

(在 Ubuntu 16.04 和 Docker 1.13 上)

当我运行尝试运行 server.js 的 dockerfile 时,出现错误:

sh: 1: node: not found

我做了一些研究,由于包冲突,名称node和nodejs发生了变化,并导致了错误;但是,当我切换到nodejs-legacy 时,它不起作用。是什么导致了这个问题?

error with nodejs

error with nodejs-legacy

<小时/>

Docker 文件

FROM ubuntu
RUN apt-get update
RUN apt-get install nodejs -y
#RUN rm -f package-lock.json
RUN apt-get install npm -y
RUN apt-get install apt-utils -y

WORKDIR /usr/scr/app

COPY package.json package-lock.json /usr/src/app/
COPY . .

EXPOSE 8080
CMD ["npm", "start"]
<小时/>

package.json

{
"name": "iam",
"version": "1.0.2",
"description": "Identity and access management.",
"main": "server.js",
"scripts": {"start": "node server.js" },
"author": "",
"license": "ISC",

"dependencies": {
"body-parser": "^1.17.2",
"cors": "^2.8.3",
"express": "^4.15.3",
"jsonwebtoken": "^7.4.1",
"ldapjs": "^1.0.1"
}
}

最佳答案

确保 CMD 命令数组之间有逗号

CMD ["node", "server.js"] 

而不是

CMD ["node" "server.js"] 

关于javascript - docker ,nodejs : node not found error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46323901/

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