WSL2 nativescript-vue 无法应用更改 ECONNREFUSED livesync

问题描述

环境

命令行界面:7.0.12

适用于 Linux 的 Windows 子系统 (WSL2)

详情

运行 tns run android 后,应用可以正常编译,但不会热重载。出现错误: 无法在设备上应用更改:emulator-5554。错误是:connect ECONNREFUSED 127.0.0.1:40547

使用--log trace后,发现端口40547(每次运行都会改变),在这个特定的运行中,可能与livesync有关。

Result when throw error is false:
{ stdout: '40547\n',stderr: '',exitCode: 0 }

spawn: /home/user/android/platform-tools/adb "-s" "emulator-5554" "shell" "rm" "-rf" "/data/local/tmp/org.nativescript.application-livesync-in-progress"
Result when throw error is false:
{ stdout: '',exitCode: 0 }
Unable to apply changes on device: emulator-5554. Error is: connect ECONNREFUSED 127.0.0.1:40547.
Error: connect ECONNREFUSED 127.0.0.1:40547
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  errno: -111,code: 'ECONNREFUSED',syscall: 'connect',address: '127.0.0.1',port: 40547
}
Will emit event runOnDeviceError with data {
  projectDir: '/home/user/code/vue-ns',deviceidentifier: 'emulator-5554',applicationIdentifier: 'org.nativescript.application',error: Error: connect ECONNREFUSED 127.0.0.1:40547
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
    errno: -111,port: 40547
  }
}
Stopping webpack watch for platform android.
Webpack process exited with code null when we expected it to be long living with watch.

复制

tns run android

预期行为

热重载。

其他上下文

尝试在 windows wsl2 中设置 nativescript-vue。让它工作。它编译正确。作为参考,我使用以下文章/文章进行设置。

  1. react-native-app-in-wsl2
  2. Using the Android emulator on Windows 10 with WSL2

我只使用了 vue init nativescript-vue/vue-cli-template 中的基本应用模板。

tns doctor

✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system,you can use the NativeScript cloud infrastructure.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 7.0.12 version and is up to date.
✔ Component @nativescript/core has 7.0.13 version and is up to date.
✖ Component @nativescript/ios is not installed.
✔ Component @nativescript/android has 7.0.1 version and is up to date.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)