小编use*_*114的帖子

使用 docker 和 nodeJS 构建简单应用程序时,如何修复错误“npm ERR!无法从路径或包中检测节点名称”?

文件

FROM node:alpine
COPY ./ ./
RUN npm install
CMD ["npm", "start"]
Run Code Online (Sandbox Code Playgroud)

索引.js

const express = require('express');
const app = express();
app.get('/', (req, res) => {
  res.send('Hi there');
});
app.listen(8080, () => {
  console.log("Listening on post 8080");
});
Run Code Online (Sandbox Code Playgroud)

包.json

{
  "dependencies": {
    "express": "*"
  },
  "scripts": {
    "start": "node index.js"
  }
}
Run Code Online (Sandbox Code Playgroud)

码头工人建造。

npm ERR! could not detect node name from path or package

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-11-23T23_36_35_301Z-debug.log
The …
Run Code Online (Sandbox Code Playgroud)

docker docker-build

10
推荐指数
1
解决办法
2292
查看次数

标签 统计

docker ×1

docker-build ×1