Npm运行构建无法引发错误代码ELIFECYCLE

时间:2018-11-05 17:53:11

标签: reactjs npm build

我想构建我编写的React JS应用程序,但是当我键入命令“ npm run build”时,出现以下错误:error。我在Internet上搜索了错误,但找不到任何解决方案来使生成的作品正常工作。请帮忙。我在下面提供了必要的代码。任何其他代码要求都将张贴在注释中。在此先感谢:)

错误日志:

    0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@6.4.1
3 info using node@v8.12.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle edaku@0.1.0~prebuild: edaku@0.1.0
6 info lifecycle edaku@0.1.0~build: edaku@0.1.0
7 verbose lifecycle edaku@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle edaku@0.1.0~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Shlloka\Desktop\edaku\node_modules\.bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\Shlloka\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\Shlloka\AppData\Local\Programs\Python\Python37\;C:\Program Files\Java\jdk1.8.0_162\bin;C:\Users\Shlloka\Desktop\curl-7.59.0-win64-mingw\bin;C:\Users\Shlloka\AppData\Local\Microsoft\WindowsApps;C:\Users\Shlloka\AppData\Roaming\npm
9 verbose lifecycle edaku@0.1.0~build: CWD: C:\Users\Shlloka\Desktop\edaku
10 silly lifecycle edaku@0.1.0~build: Args: [ '/d /s /c', 'react-scripts build' ]
11 silly lifecycle edaku@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle edaku@0.1.0~build: Failed to exec build script
13 verbose stack Error: edaku@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:915:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid edaku@0.1.0
15 verbose cwd C:\Users\Shlloka\Desktop\edaku
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v8.12.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error edaku@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the edaku@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 [ 1, true ]

package.json:

{
  "name": "edaku",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@dvsl/zoomcharts": "^1.18.9-nightly",
    "aos": "^3.0.0-beta.6",
    "apexcharts": "^2.1.9",
    "jquery": "^3.3.1",
    "nodemailer": "^4.6.8",
    "raphael": "^2.2.7",
    "react": "^16.5.2",
    "react-apexcharts": "^1.0.10",
    "react-dom": "^16.5.2",
    "react-graph-vis": "^1.0.2",
    "react-mail-form": "^1.0.1",
    "react-modal": "^3.6.1",
    "react-modal-dialog": "^4.0.7",
    "react-particle-animation": "^1.0.1",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.0.4",
    "react-transition-group": "^1.2.1",
    "reactjs-popup": "^1.3.0",
    "typed.js": "^2.0.9",
    "typeit": "^5.10.7",
    "typewriter-effect": "^2.4.6"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "webpack-cli": "^3.1.2"
  }
}

webpack.config.js:

import ExtractTextPlugin from 'extract-text-webpack-plugin';
import OptimizeCssAssetsPlugin from '../../../src/';

module.exports = {
  entry: './index',
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
          fallback: { loader: 'style-loader' },
          use: {
            loader: 'css-loader',
            options: { minimize: true }
          }
        })
      },
    ],
  },
  plugins: [
    new ExtractTextPlugin('file.css'),
    new OptimizeCssAssetsPlugin()
  ],
};

2 个答案:

答案 0 :(得分:0)

第二天,我在这里发布了这个问题,我解决了这个问题。显然,很难跟踪NPM构建可能在哪里失败。我按特定顺序编写了我的应用程序,并逐步添加了功能。因此,我评论了除最基本功能的代码以外的所有内容,然后再次尝试构建,这是成功的。这样,我在构建的进一步迭代中包含了越来越多的代码,并且能够跟踪导致整个应用程序构建失败的两行CSS代码。我建议每个收到此错误的人都不要失去希望,并继续调试,直到使它起作用为止。 :)

答案 1 :(得分:0)

我为此找到了最佳解决方案。 在输入npm run build之前,我只是做了sudo bash,然后给出了一个对我真正有用的命令npm run build