firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.02k stars 936 forks source link

Firebase hosting/deploying does not work for SvelteKit when using TypeScript #5909

Closed de-ich closed 1 year ago

de-ich commented 1 year ago

[REQUIRED] Environment info

firebase-tools: 12.2.1

Platform: Windows

[REQUIRED] Test case

Create a new SvelteKit demo app with TypeScript support, create and initialize a firebase project with hosting and try to start emulators/deploy.

[REQUIRED] Steps to reproduce

npm create svelte@latest ┌ Welcome to SvelteKit! │ ◇ Which Svelte app template? │ SvelteKit demo app │ │ Yes, using TypeScript syntax │ ◇ Select additional options (use arrow keys/space bar) │ none │ └ Your project is ready!

cd

npm install

firebase init ? Detected an existing SvelteKit codebase in the current directory, should we use this? Yes ? In which region would you like to host server-side content, if applicable? europe-west1 (Belgium) ? Set up automatic builds and deploys with GitHub? No

firebase emulators:start i emulators: Starting emulators: hosting

Thank you for trying our experimental support for SvelteKit on Firebase Hosting. While this integration is maintained by Googlers it is not a supported Firebase product. Issues filed on GitHub will be addressed on a best-effort basis by maintainers and other community members.

Documentation: https://firebase.google.com/docs/hosting/frameworks/frameworks-overview File a bug: https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md Submit a feature request: https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md

We'd love to learn from you. Express your interest in helping us shape the future of Firebase Hosting: https://goo.gle/41enW5X

i emulators: Shutting down emulators. i hub: Stopping emulator hub

Error: Could not find the vite executable.

[REQUIRED] Expected behavior

Emulators should start correclty.

[REQUIRED] Actual behavior

Emulator does not start but shows error message "Could not find the vite executable." as shown in the steps to reproduce above. The same happens when running "firebase deploy".

The error does seem to have something to do with TypeScript support because executing the exact same steps except choosing no TypeScript support when executing "npm create svelte@latest " lets the emulator start as expected.

aalej commented 1 year ago

Hi @de-ich, thanks for reaching out to us and for providing details on how to reproduce the issue. I tried to replicate this by following the steps you provided, but I was able to start the Firebase Hosting emulator without any issues.

Could you try running firebase emulators:start --debug and share the output with us? Passing the --debug flag provides a more detailed log that we can use to check what caused the error.

I’m using the following to try and replicate the issue:

de-ich commented 1 year ago

Hi @aalej,

thank you. Of course, here is the debug log:

firebase emulators:start --debug

[2023-05-31T06:01:48.415Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2023-05-31T06:01:48.417Z] > authorizing via signed-in user (xxx@xxx.xxx)
i  emulators: Starting emulators: hosting {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: hosting"}}
[2023-05-31T06:01:48.435Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-05-31T06:01:48.436Z] [hosting] Hosting Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-05-31T06:01:48.437Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"hosting":[{"address":"127.0.0.1","family":"IPv4","port":5000}]},"metadata":{"message":"assigned listening specs for emulators"}}
[2023-05-31T06:01:48.452Z] [hub] writing locator at C:\Users\Matthias\AppData\Local\Temp\hub-mfrd-hosting-test.json
[2023-05-31T06:01:48.499Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/mfrd-hosting-test [none]
[2023-05-31T06:01:49.270Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/mfrd-hosting-test 200
[2023-05-31T06:01:49.271Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/mfrd-hosting-test {"projectId":"mfrd-hosting-test","projectNumber":"176220340145","displayName":"mfrd-hosting-test","name":"projects/mfrd-hosting-test","resources":{"hostingSite":"mfrd-hosting-test"},"state":"ACTIVE","etag":"1_0ec46970-ffd0-45c3-ae72-6af129898551"}

 (x2)
 (x3)

   Thank you for trying our experimental support for Svelte on Firebase Hosting.
   While this integration is maintained by Googlers it is not a supported Firebase product.
   Issues filed on GitHub will be addressed on a best-effort basis by maintainers and other community members.

   Documentation: https://firebase.google.com/docs/hosting/frameworks/frameworks-overview
   File a bug: https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md
   Submit a feature request: https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md

   We'd love to learn from you. Express your interest in helping us shape the future of Firebase Hosting: https://goo.gle/41enW5X

i  emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}
i  hub: Stopping emulator hub {"metadata":{"emulator":{"name":"hub"},"message":"Stopping emulator hub"}}

Error: Could not find the vite executable.

To me, this does not seem to be of much help. Maybe some more information that could be of interest:

de-ich commented 1 year ago

Well that's strange. I just restarted my VSCode and now everything seems to work fine for the project I just created in order to provide the information for my answer some seconds ago.

The mysterious thing is that trying to start the emulator for another project still fails with the same error message ('Could not find the vite executable'). I guess I need to investigate a little bit deeper under which circumstances the error occurs...

de-ich commented 1 year ago

I just tried the exact same steps another couple of times and everything worked as intended. Also I was able to make it work in my original project by deleting the node-modules folder and re-running npm install (although I also tried that before and it did not help back then). I have no idea what changed but as I am not able to reproduce the bug any longer, I guess we can close it...

Thanks anyway. :)

de-ich commented 1 year ago

Yet another update: I just encountered the error once more and it seems that the problem is actually caused by VSCode:

I have no idea what the root cause is, however. Maybe some files are locked by VSCode...

aalej commented 1 year ago

From what I can gather, the issue looks more related to VSCode terminal running commands. Given that the issue does not seem specific to the Firebase CLI, I don’t think there is much we can do on our end. I would recommend filing an issue to the VSCode repository.

With that said, I’ll be closing this issue. Feel free to ask this to be reopened If you feel like I’ve made a mistake. Thanks!