nanoserver: "Error: Cannot find module node.exe" in Docker
nanoserver: "Error: Cannot find module node.exe" in Docker
尝试 运行 MS Nanoserver 上的 Nodejs
安装成功,但是当我运行 "node app.js",我得到这个错误
码头文件
FROM microsoft/nanoserver
ADD https://nodejs.org/dist/v10.4.0/node-v10.4.0-win-x64.zip C:\build\node-v10.4.0-win-x64.zip
RUN powershell -Command Expand-Archive C:\build\node-v10.4.0-win-x64.zip C:\; Rename-Item C:\node-v10.4.0-win-x64 node
ENTRYPOINT C:\node\node.exe
RUN SETX PATH C:\node
RUN SETX PATH "%path%;C:\node"
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD [ "node.exe" , "app.js" ]
EXPOSE 8081
错误:
Error: Cannot find module 'C:\app\node.exe'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:238:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
查看文档:https://docs.docker.com/engine/reference/builder/#known-issues-run。如果您使用的是 ENTRYPOINT 指令,那么 CMD 可以选择它:
CMD ["app.js"]
尝试 运行 MS Nanoserver 上的 Nodejs 安装成功,但是当我运行 "node app.js",我得到这个错误
码头文件
FROM microsoft/nanoserver
ADD https://nodejs.org/dist/v10.4.0/node-v10.4.0-win-x64.zip C:\build\node-v10.4.0-win-x64.zip
RUN powershell -Command Expand-Archive C:\build\node-v10.4.0-win-x64.zip C:\; Rename-Item C:\node-v10.4.0-win-x64 node
ENTRYPOINT C:\node\node.exe
RUN SETX PATH C:\node
RUN SETX PATH "%path%;C:\node"
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD [ "node.exe" , "app.js" ]
EXPOSE 8081
错误:
Error: Cannot find module 'C:\app\node.exe'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:238:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
查看文档:https://docs.docker.com/engine/reference/builder/#known-issues-run。如果您使用的是 ENTRYPOINT 指令,那么 CMD 可以选择它:
CMD ["app.js"]