tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] 2.0.0-rc.5 with Angular/ng serve not working on Windows

Open cjacobemotic opened this issue 1 year ago • 1 comments

Describe the bug

On Windows 10. I wanted to try android development with the alpha 2.0.0 and Angular front-end

Env :

  • Windows 10
  • Node : 20.16.0
  • npm : 10.8.1
  • CLI : Powershell 7.4.2

What I have done :

  • Create a new project with tauri cli and use last alpha (2.0.0-rc,5) : $env:CTA_ARGS="--rc"; irm https://create.tauri.app/ps | iex
  • cd tauri-angular
  • npm i
  • npm run tauri dev

Error : `npm run tauri dev

[email protected] tauri tauri dev Running BeforeDevCommand (npm run start -- --host $HOST --public-host $HOST) [email protected] start ng serve --host $HOST --public-host $HOST

Warning: This is a simple server for use in testing or debugging Angular applications locally.....

An unhandled exception occurred: getaddrinfo ENOTFOUND $HOST See "C:\Users\C9D91~1.JAC\AppData\Local\Temp\ng-sBWwg8\angular-errors.log" for further details. Error The "beforeDevCommand" terminated with a non-zero status code.`


Looks like the HOST env variable is not available to the command but as it's tauri cli trying to launch it, I can't do much to set up HOST, I tried to set it before running the command like: $env:HOST='localhost:4200'; npm run tauri dev

I also tried to use Git Bash shell, but same error. I also used WSL, to have a try on Ubuntu. I don't have that issue.

As npm run tauri dev don't succeed to launch ng serve, npm run tauri android dev does'nt work either

Reproduction

  • Create a new project with tauri cli and use last alpha (2.0.0-rc,5) : $env:CTA_ARGS="--rc"; irm https://create.tauri.app/ps | iex
  • cd tauri-angular
  • npm i
  • npm run tauri dev

Expected behavior

To launch the application

Full tauri info output

npm run tauri info

> [email protected] tauri
> tauri info


[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 127.0.2651.105
    ✔ MSVC: Visual Studio Build Tools 2022
    ✔ rustc: 1.80.1 (3f5fd8dd4 2024-08-06)
    ✔ cargo: 1.80.1 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.16.0
    - npm: 10.8.1

[-] Packages
    - tauri [RUST]: 2.0.0-rc.5
    - tauri-build [RUST]: 2.0.0-rc.5
    - wry [RUST]: 0.42.0
    - tao [RUST]: 0.29.1
    - @tauri-apps/api [NPM]: 2.0.0-rc.2
    - @tauri-apps/cli [NPM]: 2.0.0-rc.6

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist/tangular/browser
    - devUrl: http://localhost:1420/
    - framework: Angular
    - bundler: Webpack

Stack trace

npm run tauri dev

> [email protected] tauri
> tauri dev

    Running BeforeDevCommand (`npm run start -- --host $HOST --public-host $HOST`)

> [email protected] start
> ng serve --host $HOST --public-host $HOST


Warning: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.

Binding this server to an open connection can result in compromising your application or       
computer. Using a different host than the one passed to the "--host" flag might result in      
websocket connection issues. You might need to use "--disable-host-check" if that's the        
case.
    
An unhandled exception occurred: getaddrinfo ENOTFOUND $HOST
See "C:\Users\C9D91~1.JAC\AppData\Local\Temp\ng-sBWwg8\angular-errors.log" for further details.
    Error The "beforeDevCommand" terminated with a non-zero status code.


-------------------------
npm run tauri android dev                          
 
> [email protected] tauri
> tauri android dev

Detected Android emulators:
  [0] Pixel_3a_API_34_extension_level_7_x86_64
  [1] Pixel_6a_API_31
  Enter an index for a emulator above.
Emulator: 1
    Info Starting emulator Pixel_6a_API_31
    Info Waiting for emulator to start...
    Info Waiting for emulator to start...
    Info Waiting for emulator to start...
    Info Waiting for emulator to start... (maybe the emulator is unauthorized or offline, run `adb devices` to check)
    Info Waiting for emulator to start... (maybe the emulator is unauthorized or offline, run `adb devices` to check)
    Info Waiting for emulator to start... (maybe the emulator is unauthorized or offline, run `adb devices` to check)
    Info Waiting for emulator to start... (maybe the emulator is unauthorized or offline, run `adb devices` to check)
    Info Detected connected device: Pixel_6a_API_31 (sdk_gphone64_x86_64) with target "x86_64-linux-android"
    Running BeforeDevCommand (`npm run start -- --host $HOST --public-host $HOST`)

> [email protected] start
> ng serve --host $HOST --public-host $HOST


Warning: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.

Binding this server to an open connection can result in compromising your application or       
computer. Using a different host than the one passed to the "--host" flag might result in      
websocket connection issues. You might need to use "--disable-host-check" if that's the        
case.
    
An unhandled exception occurred: getaddrinfo ENOTFOUND $HOST
See "C:\Users\C9D91~1.JAC\AppData\Local\Temp\ng-IH06Hy\angular-errors.log" for further details.
    Error The "beforeDevCommand" terminated with a non-zero status code.

Additional context

Powershell version : $PsVersionTable.PSVersion

Major Minor Patch PreReleaseLabel BuildLabel


7 4 2 No response

cjacobemotic avatar Aug 22 '24 08:08 cjacobemotic

I do for belive that at least for the desktop target this is a bug in create-tauri-app https://github.com/tauri-apps/create-tauri-app/issues/765 The fix that has worked for me is to edit the src-tauri/tauri.conf.json file and replace "beforeDevCommand": "pnpm start --host $HOST --public-host $HOST" with "beforeDevCommand": "pnpm start"

b6k-dev avatar Aug 28 '24 15:08 b6k-dev

fix in https://github.com/tauri-apps/create-tauri-app/pull/768

amrbashir avatar Sep 03 '24 02:09 amrbashir