【问题标题】:How to debug webpack 'Executing webpack failed with exit code 0' in Nativescript-Vue如何在 Nativescript-Vue 中调试 webpack 'Executing webpack failed with exit code 0'
【发布时间】:2020-07-13 00:15:51
【问题描述】:

我尝试将 NativeScript-Vue 项目从 NativeScript 版本 6.2.1 更新到 6.5.0(遵循 upgrade instructions)。尝试通过“tns run android”运行项目失败,几乎没有提供有关原因的信息:

File change detected. Starting incremental webpack compilation...

webpack is watching the files…

Executing webpack failed with exit code 0

我对 webpack 了解不多,但是 0 应该是成功的吧?无论如何,我认为导致构建失败的任何原因都可能是在某处被吞没的错误。所以我尝试通过向 webpack-cli:s 代码(在 node_modules/.bin/webpack 中)添加几十个 console.logs 来调试,看看是否发生了奇怪的事情。但我什么也找不到(我也不知道去哪里找)。只有一个地方没有参数显式调用 process.exit()(退出代码默认为 0),但在我的情况下从未进行过调用。

我想知道是否有一些方法可以在 NativeScript-vue 项目中调试 webpack 有用?我在配置中添加了stats: 'verbose'bail: true,但这并没有做任何事情。

以下是 package.json 中我认为相关的部分:

  "nativescript": {
    ...
    "tns-ios": {
      "version": "6.5.0"
    },
    "tns-android": {
      "version": "6.5.0"
    }
  },
  "dependencies": {
    ...
    "@vue/devtools": "^5.3.3",
    "nativescript": "^6.5.0",
    "nativescript-vue": "^2.5.1",
    "tns-core-modules-widgets": "^6.5.0",
    ...
  }
  "devDependencies": {
    ...
    "nativescript-dev-webpack": "~1.5.1",
    "nativescript-vue-template-compiler": "^2.5.1",
    "vue-loader": "^15.9.1"
    ...
  },

[编辑:] 编译失败似乎是因为 NS 和 NativeScript-Vue 之间的兼容性问题,因为 NativeScript-Vue 2.5.1 有一个旧版本的 NativeScript 作为其依赖项。

不过,我想知道是否有办法调试 webpack 以找到导致编译失败的根源。

[Edit2:] 已更新至支持 NS 6.5.0 的 NS-Vue 2.6.1,但问题仍然存在。

使用 --log 跟踪选项会产生一些额外的日志行。以下为tnsrun android

Webpack process exited with code 0 when we expected it to be long living with watch.
Error while executing action on device emulator-5554. The error is { Error: Executing webpack failed with exit code 0.
    at WebpackCompilerService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/webpack/webpack-compiler-service.js:102:39)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/nativescript/lib/services/webpack/webpack-compiler-service.js:10:58)
    at process._tickCallback (internal/process/next_tick.js:68:7) code: 0, deviceIdentifier: 'emulator-5554' }
Executing webpack failed with exit code 0.

运行tns build android 产生:

15:35:35.828 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Received result Success[value=org.gradle.launcher.exec.BuildActionResult@79d8407f] from daemon DaemonInfo{pid=7854, address=[20952e36-f07a-456e-9283-61c96877e6d3 port:39999, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], state=Idle, lastBusy=1588854861253, context=DefaultDaemonContext[uid=897270b3-048d-4379-9e18-2b62285c66ff,javaHome=/usr/local/java/jdk1.8.0_211,daemonRegistryDir=/home/jesse/.gradle/daemon,pid=7854,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xmx16384M,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).
15:35:35.829 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: dispatching class org.gradle.launcher.daemon.protocol.Finished
15:35:35.829 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: connection stop
Command ./gradlew failed with exit code 1
Error: Command ./gradlew failed with exit code 1
    at Errors.failWithOptions (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:147:28)
    at Errors.fail (/usr/local/lib/node_modules/nativescript/lib/common/errors.js:120:21)
    at GradleCommandService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/android/gradle-command-service.js:35:30)
    at Generator.throw (<anonymous>)
    at rejected (/usr/local/lib/node_modules/nativescript/lib/services/android/gradle-command-service.js:5:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)

有趣的是,调试日志显示“收到结果成功”和“应该完成构建”,但 gradlew 仍然失败。

【问题讨论】:

    标签: webpack nativescript-vue


    【解决方案1】:

    问题原来是包 nativescript-worker-loader@0.11 中的一个错误。目前,该软件包需要降级到 v0.10 才能正常工作。

    感谢NathanaelAanswer

    对于那些感兴趣的人,这里是 an issue 关于这个问题,已经有 NathanaelA 提交的待处理 PR。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-22
      • 2021-09-04
      • 2020-11-06
      • 1970-01-01
      • 2019-02-10
      • 2022-12-28
      • 2018-12-12
      • 1970-01-01
      相关资源
      最近更新 更多