微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。