This is my Dockerfile:
FROM node:12
WORKDIR /app
COPY . /app
RUN npm install
EXPOSE 3000
CMD ["npm", "start"]
This is the npm script in my package.json
"start": "main.js $npm_config_e $npm_config_t"
when I run the docker image I get this error
sh: 1: main.js: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! image1@1.0.0 start: `main.js`
However when I do an 'ls' the main.js is in the working directory (/app) also if I change the Dockerfile to:
CMD ["node", "main.js"]
it works. So why does the npm script not find the main.js file?
现在看起来很明显,但解决方案是将节点添加到 npm 脚本中:
"start": "node main.js $npm_config_e $npm_config_t"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.