Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Docker build无法在web上运行:';运行npx网页包';——不';不要在dockerfile中移动到下一步_Node.js_Reactjs_Docker_Webpack_Containers - Fatal编程技术网

Node.js Docker build无法在web上运行:';运行npx网页包';——不';不要在dockerfile中移动到下一步

Node.js Docker build无法在web上运行:';运行npx网页包';——不';不要在dockerfile中移动到下一步,node.js,reactjs,docker,webpack,containers,Node.js,Reactjs,Docker,Webpack,Containers,我正在尝试使用以下dockerfile将我的项目构建到Docker的容器中: FROM node:10 WORKDIR /usr/app/battlejong COPY client ./client COPY BattleJongServer ./BattleJongServer WORKDIR /usr/app/battlejong/client RUN npm install RUN npx webpack WORKDIR /usr/app/battlejong/BattleJongSer

我正在尝试使用以下dockerfile将我的项目构建到Docker的容器中:

FROM node:10
WORKDIR /usr/app/battlejong
COPY client ./client
COPY BattleJongServer ./BattleJongServer
WORKDIR /usr/app/battlejong/client
RUN npm install
RUN npx webpack
WORKDIR /usr/app/battlejong/BattleJongServer
RUN npm install
RUN npx tsc
EXPOSE 80
CMD ["node","./dist/main.js"]
docker build运行并完成webpack步骤,但不会继续到更改目录的下一步

以下是此处的输出:

Step 1/12 : FROM node:10
 ---> 1e318dc8ae6f
Step 2/12 : WORKDIR /usr/app/battlejong
 ---> Using cache
 ---> c004d781a932
Step 3/12 : COPY client ./client
 ---> 955204bda599
Step 4/12 : COPY BattleJongServer ./BattleJongServer
 ---> 6c692d4c4bad
Step 5/12 : WORKDIR /usr/app/battlejong/client
 ---> Running in 662e29660e6c
Removing intermediate container 662e29660e6c
 ---> 3ce3c61bf582
Step 6/12 : RUN npm install
 ---> Running in 808724a44e9b
npm WARN client@1.0.0 No description
npm WARN client@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 678 packages from 430 contributors and audited 684 packages in 12.37s

29 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Removing intermediate container 808724a44e9b
 ---> 0dc996f51895
Step 7/12 : RUN npx webpack
 ---> Running in bd591d5fc8f8

webpack is watching the files…

ℹ 「atl」: Using typescript@4.0.2 from typescript
ℹ 「atl」: Using tsconfig.json from /usr/app/battlejong/client/tsconfig.json
ℹ 「atl」: Checking started in a separate process...
ℹ 「atl」: Time: 1712ms
Hash: 99e556545c8a1a30d23c
Version: webpack 4.44.1
Time: 9256ms
Built at: 09/15/2020 12:10:54 AM
       Asset       Size  Chunks                          Chunk Names
./index.html  241 bytes          [emitted]               
     main.js    276 KiB       0  [emitted]        [big]  main
 main.js.map    508 KiB       0  [emitted] [dev]         main
Entrypoint main [big] = main.js main.js.map
 [4] ./src/code/main.tsx 550 bytes {0} [built]
 [7] ./src/css/main.css 524 bytes {0} [built]
 [8] ./node_modules/css-loader/dist/cjs.js!./src/css/main.css 3.39 KiB {0} [built]
[17] ./src/img/tile101.png 5.59 KiB {0} [built]
[18] ./src/img/tile102.png 3.15 KiB {0} [built]
[19] ./src/img/tile103.png 2.58 KiB {0} [built]
[20] ./src/img/tile104.png 1.14 KiB {0} [built]
[21] ./src/img/tile105.png 2.39 KiB {0} [built]
[22] ./src/img/tile106.png 2.1 KiB {0} [built]
[23] ./src/img/tile107.png 3.49 KiB {0} [built]
[24] ./src/img/tile108.png 2.53 KiB {0} [built]
[25] ./src/img/tile109.png 2.53 KiB {0} [built]
[26] ./src/img/tile110.png 2.29 KiB {0} [built]
[27] ./src/img/tile111.png 1.58 KiB {0} [built]
[59] ./src/code/state.tsx 12.9 KiB {0} [built]
    + 46 hidden modules

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
Child HtmlWebpackCompiler:
     1 asset
    Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0
    [0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 287 bytes {0} [built]
然后构建不会从这里开始进入dockerfile中的第8行/步骤,而是一直坐在这里,直到我强制停止构建

这也是我的package.json:

  {
  "name": "client",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "scripts": {
    "start": "npx webpack"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/react": "^16.9.44",
    "@types/react-dom": "^16.9.8",
    "awesome-typescript-loader": "^5.2.1",
    "css-loader": "^4.2.2",
    "html-loader": "^1.3.0",
    "html-webpack-plugin": "^4.4.1",
    "style-loader": "^1.2.1",
    "typescript": "^4.0.2",
    "url-loader": "^4.1.0",
    "webpack": "^4.44.1",
    "webpack-cli": "^3.3.12",
    "webpack-dev-server": "^3.11.0"
  },
  "mode": "production",
  "dependencies": {
    "normalize.css": "^8.0.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1"
  }
}

我一直在遵循一个教程,他们的dockerfile也是一样的,所以任何提示都将不胜感激

webpack.config.js
中是否有东西将其设置为自动重建模式?“网页正在查看文件”诊断对我来说是可疑的。@DavidMaze嗨,David,很抱歉反应太晚了!这是我的问题-谢谢你!