我有一个华硕,我想对接我的节点js应用程序,以便能够随时运行。我遵循official tutorial from nodejs,但它没有工作,因为我的nas上的预期,而在我的电脑上一切都很好。
下面是我的Dockerfile:
FROM node:latest
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["node", "app.js"]
下面是我在NAS上遇到的错误:
Sending build context to Docker daemon 45.57kB
Step 1/7 : FROM node:latest
---> b254e440661a
Step 2/7 : WORKDIR /app
---> Running in 4ddb713a2c92
Removing intermediate container 4ddb713a2c92
---> 7956afe6d600
Step 3/7 : COPY package*.json ./
---> 9a814bfae80d
Step 4/7 : RUN npm install
---> Running in 477d3abd6312
node:internal/fs/utils:347
throw err;
^
Error: ENOENT: no such file or directory, open '/usr/local/lib/cli.js'
at Object.openSync (node:fs:591:3)
at Object.readFileSync (node:fs:459:35)
at Module._extensions..js (node:internal/modules/cjs/loader:1222:18)
at Module.load (node:internal/modules/cjs/loader:1068:32)
at Module._load (node:internal/modules/cjs/loader:909:12)
at Module.require (node:internal/modules/cjs/loader:1092:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/usr/local/bin/npm:2:1)
at Module._compile (node:internal/modules/cjs/loader:1205:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1259:10) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/usr/local/lib/cli.js'
}
Node.js v19.1.0
The command '/bin/sh -c npm install' returned a non-zero code: 1
1条答案
按热度按时间mrphzbgm1#
从您发送的官方指南中,您可以在以下链接中清楚地看到,我在主指南和您的Dockerfile中突出显示了他们使用的版本您使用的是
FROM node:latest
,同时他们使用的是node:10
,您能否编辑您的Dockerfile并将latest
更改为10
,以便将节点版本修复到