firebase-tools: Could not find the next executable

Environment info node 16.16.0

npm 8.11.0

firebase-tools: 12.4.4

Platform: nextjs

Test case

Steps to reproduce:

1 create nextjs project 2 firebase init 3 firebase deploy

Expected behavior: deploy nextjs project to firebase hosting

Actual behavior:

[info] Thank you for trying our early preview of Next.js support on Firebase Hosting. During the preview, support is best-effort and breaking changes can be expected. Proceed with caution.

Documentation: https://firebase.google.com/docs/hosting/frameworks/nextjs 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

[error] [error] Error: Could not find the next executable.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 10
  • Comments: 33 (8 by maintainers)

Most upvoted comments

I am facing the same problem when deploying using Github action. The deployment is working like a charm locally on my computer using firebase cli.

Thanks everyone for providing detailed information about the issue. I was able to reproduce it and found that the root cause is in the build step performed by the CLI, where npm root runs multiple times. There was a 2 seconds timeout and depending on the CPU this could take longer. I submitted a fix in #6372 which will be available in the next release.

This issue is limited to Windows only - and changing source to public in firebase.json doesn’t work.

This is was worked for me:

There is actually a bug with the correct dependencies (if you want to know how i came to this conclusion, read my earlier post on this page).

Fix your project the fast way: npm i -g firebase-tools@11.29.0 and after that npm i firebase@^9.9.0 and run firebase deploy (for the 4793457024753rd time).

Same issue. Weirdly enough, setting the next distDir to out got me further along in the process but it still failed.

(Update) This works on a very limited scope Things that don’t work with this solution:

  • Assets
  • Routing
  • Anything that’s not static.

Sorry for the false hope…

(Original) Here’s what worked.

  1. Run npm run build (or whatever builds your app)
  2. Rename the build file to _next (the build file is probably .next)
  3. Change source: "." to public: "." in your firebase.json file
  4. Go to _next/server/app and copy the index.html file to the same level as your _next directory.
  5. Run firebase deploy for the 4793457024752 time.

Hopefully this works for you as well. Best of luck!

here is the debug file

[debug] [2023-08-10T15:58:28.697Z] ---------------------------------------------------------------------- [debug] [2023-08-10T15:58:28.701Z] Command: C:\Program Files\nodejs\node.exe C:\Users\username\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js deploy --debug [debug] [2023-08-10T15:58:28.702Z] CLI Version: 12.4.7 [debug] [2023-08-10T15:58:28.703Z] Platform: win32 [debug] [2023-08-10T15:58:28.703Z] Node Version: v18.16.1 [debug] [2023-08-10T15:58:28.705Z] Time: Thu Aug 10 2023 20:58:28 G-00500 (Standard Time) [debug] [2023-08-10T15:58:28.705Z] ---------------------------------------------------------------------- [debug] [debug] [2023-08-10T15:58:28.889Z] > 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”] [debug] [2023-08-10T15:58:28.893Z] > authorizing via signed-in user (email@gmail.com) [debug] [2023-08-10T15:58:28.894Z] [iam] checking project <projectId> for permissions [“firebase.projects.get”,“firebasehosting.sites.update”] [debug] [2023-08-10T15:58:28.899Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/projectId:testIamPermissions [none] [debug] [2023-08-10T15:58:28.900Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/projectId:testIamPermissions x-goog-quota-user=projects/projectId [debug] [2023-08-10T15:58:28.902Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/projectId:testIamPermissions {“permissions”:[“firebase.projects.get”,“firebasehosting.sites.update”]} [debug] [2023-08-10T15:58:30.845Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/projectId:testIamPermissions 200 [debug] [2023-08-10T15:58:30.847Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/projectId:testIamPermissions {“permissions”:[“firebase.projects.get”,“firebasehosting.sites.update”]} [debug] [2023-08-10T15:58:30.851Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/projectId [none] [debug] [2023-08-10T15:58:31.658Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/projectId 200 [debug] [2023-08-10T15:58:31.660Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/projectId {“projectId”:“projectId”,“projectNumber”:“<>”,“displayName”:“<>”,“name”:“projects/projectId”,“resources”:{“hostingSite”:“projectId”},“state”:“ACTIVE”,“etag”:“<>”} [info] Thank you for trying our early preview of Next.js support on Firebase Hosting. During the preview, support is best-effort and breaking changes can be expected. Proceed with caution.

Documentation: https://firebase.google.com/docs/hosting/frameworks/nextjs 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

[error] [error] Error: Error finding next executable: failed to spawn ‘npm’

I am on windows. Same behaviour.

So, nobody on windows is able to deploy their Next.js project to firebase hosting right now? 😦

[debug] [2023-07-26T13:58:04.741Z] ---------------------------------------------------------------------- [debug] [2023-07-26T13:58:04.745Z] Command: C:\Program Files\nodejs\node.exe C:\Users<username>\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js deploy --debug [debug] [2023-07-26T13:58:04.746Z] CLI Version: 12.4.6 [debug] [2023-07-26T13:58:04.746Z] Platform: win32 [debug] [2023-07-26T13:58:04.746Z] Node Version: v18.16.1 [debug] [2023-07-26T13:58:04.748Z] Time: Wed Jul 26 2023 18:58:04 GMT+0900 (Time) [debug] [2023-07-26T13:58:04.748Z] ---------------------------------------------------------------------- [debug] [debug] [2023-07-26T13:58:04.934Z] > 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”] [debug] [2023-07-26T13:58:04.938Z] > authorizing via signed-in user (email@gmail.com) [debug] [2023-07-26T13:58:04.940Z] [iam] checking project project01 for permissions [“firebase.projects.get”,“firebasehosting.sites.update”] [debug] [2023-07-26T13:58:04.947Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/project01:testIamPermissions [none] [debug] [2023-07-26T13:58:04.948Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/project01:testIamPermissions x-goog-quota-user=projects/project01 [debug] [2023-07-26T13:58:04.952Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/project01:testIamPermissions {“permissions”:[“firebase.projects.get”,“firebasehosting.sites.update”]} [debug] [2023-07-26T13:58:06.730Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/project01:testIamPermissions 200 [debug] [2023-07-26T13:58:06.732Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/project01:testIamPermissions {“permissions”:[“firebase.projects.get”,“firebasehosting.sites.update”]} [debug] [2023-07-26T13:58:06.735Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/project01 [none] [debug] [2023-07-26T13:58:07.341Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/project01 200 [debug] [2023-07-26T13:58:07.342Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/project01 {“projectId”:“project01”,“projectNumber”:“<number>”,“displayName”:“user”,“name”:“projects/project01”,“resources”:{“hostingSite”:“project01”},“state”:“ACTIVE”,“etag”:“–”} [info] Thank you for trying our early preview of Next.js support on Firebase Hosting. During the preview, support is best-effort and breaking changes can be expected. Proceed with caution.

Documentation: https://firebase.google.com/docs/hosting/frameworks/nextjs 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

[error] [error] Error: Could not find the next executable.