npm run build 抛出错误代码 ELIFECYCLE

基尔代卡

我一直在关注 Wes Bos 系列“所有人的 ES6”有一段时间了,但我被一个 webpack 剧集困住了。每当我尝试在我的 CMD 上运行“npm run build”命令时,我都会收到此错误:

npm 错误!代码 ELIFECYCLE npm ERR!错误号 1 npm 错误号![email protected] 构建:webpack --progress --watchnpm ERR!退出状态 1 npm ERR!npm 错误![email protected] 构建脚本失败。npm 错误!这可能不是 npm 的问题。上面可能有额外的日志输出。

在网上搜索了各种解决方案后,我最终在这里希望你们能帮助我。这是运行命令的日志文件:

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 @5 .6 .0
3 info using node @v8 .10 .0
4 verbose run - script['prebuild', 'build', 'postbuild']
5 info lifecycle webpacktest @1 .0 .0~prebuild: webpacktest @1 .0 .0
6 info lifecycle webpacktest @1 .0 .0~build: webpacktest @1 .0 .0
7 verbose lifecycle webpacktest @1 .0 .0~build: unsafe - perm in lifecycle true
8 verbose lifecycle webpacktest @1 .0 .0~build: PATH: C: \Program Files\ nodejs\ node_modules\ npm\ node_modules\ npm - lifecycle\ node - gyp - bin;
C: \Users\ Laurynas\ Desktop\ es6.io - master\ New folder\ webpacktest\ node_modules\.bin;
C: \ProgramData\ Oracle\ Java\ javapath;
C: \Windows\ system32;
C: \Windows;
C: \Windows\ System32\ Wbem;
C: \Windows\ System32\ WindowsPowerShell\ v1 .0\;
C: \Program Files(x86)\ NVIDIA Corporation\ PhysX\ Common;
C: \Program Files(x86)\ GtkSharp\ 2.12\ bin;
C: \Program Files\ nodejs\;
C: \Program Files\ Git\ cmd;
C: \Users\ Laurynas\ AppData\ Roaming\ npm;
C: \Program Files\ Microsoft VS Code\ bin
9 verbose lifecycle webpacktest @1 .0 .0~build: CWD: C: \Users\ Laurynas\ Desktop\ es6.io - master\ New folder\ webpacktest
10 silly lifecycle webpacktest @1 .0 .0~build: Args: ['/d /s /c', 'webpack --progress --watch']
11 silly lifecycle webpacktest @1 .0 .0~build: Returned: code: 1 signal: null
12 info lifecycle webpacktest @1 .0 .0~build: Failed to exec build script
13 verbose stack Error: webpacktest @1 .0 .0 build: `webpack --progress --watch`
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: 285: 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: 925: 16)
13 verbose stack at Process.ChildProcess._handle.onexit(internal / child_process.js: 209: 5)
14 verbose pkgid webpacktest @1 .0 .0
15 verbose cwd C: \Users\ Laurynas\ Desktop\ es6.io - master\ New folder\ webpacktest
16 verbose Windows_NT 10.0 .10586
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 .10 .0
19 verbose npm v5 .6 .0
20 error code ELIFECYCLE
21 error errno 1
22 error webpacktest @1 .0 .0 build: `webpack --progress --watch`
22 error Exit status 1
23 error Failed at the webpacktest @1 .0 .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 文件。起初它有这样的内容(它在教程中完全像这样显示”

const webpack = require('webpack');
const nodeEnv = process.env.NODE_ENV || 'production';

module.exports = {
  devtool: 'source-map',
  entry: {
    filename: './app.js'
  },
  output: {
    filename: '_build/bundle.js'
  },
  module: {
    loaders: [{
      test: /\.js$/,
      exclude: /node_modules/,
      loader: 'babel-loader',
      query: {
        presets: ['es2015-native-modules']
      }
    }]
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      },
      output: {
        comments: false
      },
      sourceMap: true
    }),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify(nodeEnv)
      }
    })
  ]
};

我将整个模块导出更改为:

module.exports = {
  entry: ['./app.js'],
  output: {
    path: __dirname + '/build',
    filename: 'bundle.js'
  }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

npm run build给出npm ERR!代码ELIFECYCLE

呃!运行npm start时输入代码ELIFECYCLE

什么是npm ERR!代码ELIFECYCLE?

运行“ npm run build”后收到npm错误:npm ERR!代码ELIFECYCLE npm ERR!错误2

npm ERR!运行npm install时的代码ELIFECYCLE

npm run build在我的vue cli项目中抛出错误,但是npm run dev可以正常工作

npm run build生成未处理的拒绝错误:SourceMap

调试npm ERR!代码ELIFECYCLE npm ERR!errno 1

npm ERR!代码ELIFECYCLE(开始发行)

使用Webpack运行npm run build时反应Typescript错误

“ vue-cli-service test:unit”成功运行;但是npm退出错误代码1 ELIFECYCLE

npm start使用MongoDB和mongoose抛出ELIFECYCLE错误

如何解决节点服务器错误,npm ERR!代码ELIFECYCLE npm ERR!errno 1?

来自npm-run-build前端的Django中的静态文件抛出错误404

如何解决npm错误“ npm ERR!代码ELIFECYCLE”

由于docker build中的TypeScript错误,npm run build失败

npm ERR!代码ELIFECYCLE npm后安装脚本

在`npm run build`时出错

尝试并发运行(npm ERR!代码 ELIFECYCLE npm ERR!)

如何解决 Linux 中的“npm ERR!code ELIFECYCLE”错误?

Laravel:CentOS 上的 npm 退出代码 1 代码 ELIFECYCLE

npm 错误!代码 ELIFECYCLE,errno ENOENT & syscall spawn

在 npm run build 之前检查 jshint 错误

运行“npm run build”时出现 npm run build 错误

Vercel 部署错误:命令“npm run build”以 1 退出

React 和 Vercel:错误:命令“npm run build”以 1 退出?

运行 npm run build 时出现 webpack 错误

我做了 npm run build 并得到了很多错误

如何运行`npm run build`