2

我使用 create-react-app 创建了一个 react 应用程序,当我第一次尝试使用 npm run build 构建它时,它运行良好。但是,经过几天的开发,当我尝试运行相同的命令时,我遇到了以下问题。

@ ./src/routes/web.js 195:0-49 390:33-44
     @ ./src/App.js
     @ ./src/index.js
     @ multi ./src/index.js
    Child html-webpack-plugin for "index.html":
         1 asset
        Entrypoint undefined = index.html
        [2] (webpack)/buildin/global.js 489 bytes {0} [built]
            [0] 63ms -> [1] 5043ms -> factory:512ms building:291ms = 5909ms
        [3] (webpack)/buildin/module.js 497 bytes {0} [built]
            [0] 63ms -> [1] 5043ms -> factory:512ms building:291ms = 5909ms
            + 2 hidden modules

运行 npm run build 时的控制台

0 info it worked if it ends with ok
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@6.4.1
3 info using node@v10.13.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle client-lms@0.1.0~prebuild: client-lms@0.1.0
6 info lifecycle client-lms@0.1.0~build: client-lms@0.1.0
7 verbose lifecycle client-lms@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle client-lms@0.1.0~build: PATH: xxx
9 verbose lifecycle client-lms@0.1.0~build: CWD: D:\lms-webpack\lms\client-lms
10 silly lifecycle client-lms@0.1.0~build: Args: [ '/d /s /c',
10 silly lifecycle   'rimraf dist && webpack --config ./webpack.production.config.js --progress --profile --colors --mode production' ]
11 silly lifecycle client-lms@0.1.0~build: Returned: code: 2  signal: null
12 info lifecycle client-lms@0.1.0~build: Failed to exec build script
13 verbose stack Error: client-lms@0.1.0 build: `rimraf dist && webpack --config ./webpack.production.config.js --progress --profile --colors --mode production`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> 
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess.<anonymous> 
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:962:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid client-lms@0.1.0
15 verbose cwd D:\lms-webpack\lms\client-lms
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v10.13.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 2
22 error client-lms@0.1.0 build: `rimraf dist && webpack --config ./webpack.production.config.js --progress --profile --colors --mode production`
22 error Exit status 2
23 error Failed at the client-lms@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

我一直在 StackOverflow 中四处寻找,但似乎找不到与我的问题类似的任何东西。通常会有某种特定的错误信息,但我看不到它。

{
  "dependencies": {
    "@babel/polyfill": "^7.0.0",
    "express": "^4.16.4",
    "pdfmake": "^0.1.36",
    "query-string": "^6.2.0",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "react-loadable": "^5.5.0",
    "react-redux": "^5.0.7",
    "react-router": "^4.2.0",
    "react-router-dom": "^4.2.2",
    "react-router-redux": "^4.0.8",
    "react-rte": "^0.15.0",
    "react-scripts": "^2.1.1",
    "react-scrollbar": "^0.5.4",
    "react-sortable-tree": "^2.3.0",
    "recharts": "^1.4.1",
    "redux": "^3.7.2",
    "redux-devtools": "^3.4.2",
    "redux-devtools-dock-monitor": "^1.1.3",
    "redux-devtools-log-monitor": "^1.4.0",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0",
    "regenerator-runtime": "^0.13.1",
    "source-map-explorer": "^1.6.0",
    "string-format-js": "^1.0.0",
    "styled-components": "^2.4.1",
    "uniqid": "^5.0.3",
    "xlsx": "^0.11.19"
  },
  "devDependencies": {
    "@babel/core": "^7.1.6",
    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
    "@babel/plugin-transform-regenerator": "^7.0.0",
    "@babel/preset-env": "^7.1.6",
    "@babel/preset-react": "^7.0.0",
    "babel-eslint": "^10.0.1",
    "babel-loader": "^8.0.4",
    "babel-minify-webpack-plugin": "^0.3.1",
    "babel-plugin-lodash": "^3.3.4",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "compression-webpack-plugin": "^2.0.0",
    "css-loader": "^1.0.1",
    "eslint": "^5.9.0",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.2",
    "eslint-plugin-react": "^7.11.1",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "file-loader": "^1.1.11",
    "html-webpack-inline-source-plugin": "0.0.10",
    "html-webpack-plugin": "^3.2.0",
    "json-loader": "^0.5.7",
    "lodash-webpack-plugin": "^0.11.5",
    "mini-css-extract-plugin": "^0.4.4",
    "node-sass": "^4.11.0",
    "optimize-css-assets-webpack-plugin": "^5.0.1",
    "rimraf": "^2.6.2",
    "sass-loader": "^7.1.0",
    "stats-webpack-plugin": "^0.7.0",
    "style-loader": "^0.23.1",
    "terser-webpack-plugin": "^1.1.0",
    "uglifyjs-webpack-plugin": "^2.0.1",
    "webpack": "^4.26.0",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.1.10"
  },
  "scripts": {
    "start": "webpack-dev-server --host 0.0.0.0 --port 3000 --config ./webpack.config.js --mode development",
    "build": "rimraf dist && webpack --config ./webpack.production.config.js --progress --profile --colors --mode production",
  }
}

提前致谢。

4

0 回答 0