firebase / firebase-tools

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

Deploying NextJS using Firebase Deploy throws "Cannot read properties of null (reading 'toString') at ɵcodegenFunctionsDirectory " #5369

Closed sanesanyo closed 1 year ago

sanesanyo commented 1 year ago

[REQUIRED] Environment info

Firebase: 9.15.0 Node.js: 18.0.0 Npm: 8.6.0

firebase-tools: 11.19.0

Platform: Windows

[REQUIRED] Test case

Deploy NextJS using Firebase deploy using the new launched experimental feature for web frameworks

[REQUIRED] Steps to reproduce

  1. Create a project using "npx create-next-app@latest"
  2. Install the latest version of Firebase CLI
  3. cd into the NextJS project and "npm install firebase"
  4. Create a .env.local file to add all the environment variables
  5. Firebase init --> choose hosting & functions
  6. npm run dev to test if everything is working fine locally (everything works)

Package.json

{ "name": "gpt3-cover-letter", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@next/font": "13.1.1", "eslint": "8.30.0", "eslint-config-next": "13.1.1", "file-saver": "^2.0.5", "firebase": "^9.15.0", "next": "^13.1.1", "openai": "^3.1.0", "react": "18.2.0", "react-dom": "18.2.0" } }

Firebase.json

{ "functions": [ { "source": "functions", "codebase": "default", "ignore": [ "node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log" ] } ], "hosting": { "source": ".", "ignore": [ "firebase.json", "*/.", "/node_modules/" ] }, "emulators": { "functions": { "port": 5001 }, "hosting": { "port": 5000 }, "ui": { "enabled": true }, "singleProjectMode": true, "auth": { "port": 9099 }, "firestore": { "port": 8080 }, "database": { "port": 9000 }, "pubsub": { "port": 8085 }, "storage": { "port": 9199 }, "eventarc": { "port": 9299 } } }

[REQUIRED] Expected behavior

When I run "firebase deploy", my NextJS is deployed.

[REQUIRED] Actual behavior

I get the following error when running "firebase deploy"

TypeError: Cannot read properties of null (reading 'toString') at ɵcodegenFunctionsDirectory (C:\Users\sanyo\AppData\Roaming\npm\node_modules\firebase-tools\lib\frameworks\next\index.js:220:18) at async prepareFrameworks (C:\Users\sanyo\AppData\Roaming\npm\node_modules\firebase-tools\lib\frameworks\index.js:305:84) at async deploy (C:\Users\sanyo\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\index.js:53:13)

sanesanyo commented 1 year ago

I think I have nailed down the issue but now I am running into a different issue. When I run "firebase deploy", it deploys my nextjs app as a cloud function using "Node 18" but then now I get the following error: package.json in functions directory has an engines field which is unsupported. Valid choices are: {"node": 10|12|14|16}

I cannot control setting the Node JS version as these cloud functions are created when I enter "firebase deploy". Any idea how I can override this error?

When I move to Node 16 version then if I use the latest firebase tools then I get the same error as above but if I use the minimum firebase tools version to use this experimental feature then I get a new kind of error. I really cannot find a way to fix this, have spent several hours already.

sanesanyo commented 1 year ago

Ok, finally I found the right firebase tools version that is minimum enough but then also I do not have the above problems i.e. version 11.14.3. I should have stuck to deploying the Next JS app using Cloud Run instead.

valentimcanejo commented 1 year ago

Hello, I need help, I'm also using this new next feature to deploy my app, but i'm facing many problems, my first one was the same as the main problem of this issue, I downgraded firebase-tools and worked, but it's appearing other problems, I need to know if you successfully deployed your next app in firebase using the hosting, if yes, could you tell me your steps?

sanesanyo commented 1 year ago

@valentimcanejo Hi, I was able to deploy successfully. FYI: It only deploys the static pages, no api routes (at least not for me and I could not find any information on the web that could help). So I deployed the api routes as cloud functions instead. Where are you getting stuck?

MarcosNotch commented 1 year ago

@sanesanyo I have the same problem

sanesanyo commented 1 year ago

@MarcosNotch So this is how I fixed this issue. I switched to Node 16 & then also install firebase tools version 11.14.3 as it meets the minimum requirement in order to deploy the Next JS app. And then course before you init hosting, you have to switch on the experimental version i.e. firebase experiments:enable webframeworks (read here for more details: https://firebase.google.com/docs/hosting/nextjs). And once you are done with init, then all you have to do is "firebase deploy" in case you also want to deploy your firebase functions otherwise "firebase deploy --only hosting" should also work. Also I would recommend first to deploy it locally using the emulator as you will be able to pinpoint the bugs more easily as you see them in the log.

Let me know in case of any questions.

Cheers, Sanyog

valentimcanejo commented 1 year ago

Hello, I got your explanation, i'm trying to deploy a hosting with firebase using nextJS, but it is a big application, using firebase collections and stuff, but I already followed many tutorials, without success. I also followed the tutorial at: https://firebase.google.com/docs/hosting/nextjs , but still doesn't works.

sanesanyo commented 1 year ago

Ok, can you please paste here what error are you getting? Also do share the versions that you are using. I do not think size of the application has much to do with the deployment.

valentimcanejo commented 1 year ago

Firstly I got the "TypeError: Cannot read properties of null (reading 'toString')", after downgrading the firebase-tools, I got the "Error: Command failed: npm i --omit dev --no-audit", I went to the firebase-tools node_modules and added manually the "--force" for this command, and after that another error appeared, about the node version of my functions folder "{"node": 10|12|14|16}".

I already tried 2 different firebase-tools versions: 11.14.3 and v11.18.0. But still not working.

sanesanyo commented 1 year ago

To the node version issue, you need to install the Node 16 version & switch to that version when deploying. I am using nvm for that, works pretty well. Try that first and see which error you see.

valentimcanejo commented 1 year ago

Man, I was trying to use the hosting because my sign in with link email from firebase was going to spam box everytime, but since I already fixed it by only changing my project name, I won't solve this hosting problem for now, because I see that I'm going to lose more time.

Anyway, thank you so much for your help and your attention, if you need any help with a firebase project involving collections and stuff, feel free to contact me.

sanesanyo commented 1 year ago

I understand. It costed me like 4-5 hours to solve this problem & clearly thinking about it now, it probably was not worth it as I think I could comfortably deploy it using Cloud Run without any issues. Anyway, thanks for your offer :). Have a nice day.

MarcosNotch commented 1 year ago

@valentimcanejo The fastest way to solve this issue is to switch to aws amplify, you can deploy next js 13 without any problems and not making 1000 configurations

1nterfect0r commented 1 year ago

I have the same error.

I tryed it also with firebase-tools v11.14.3.

It worked with with firebase-tools v11.18.0

Console:

firebase deploy
Detected a Next.js codebase. This is an experimental integration, proceed with caution.

warn  - You have enabled experimental feature (appDir) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

info  - Creating an optimized production build  
info  - Compiled successfully
info  - Linting and checking validity of types  
info  - Collecting page data  
info  - Generating static pages (9/9)
info  - Finalizing page optimization

[...]

Building a Cloud Function to run this application. This is needed due to:
 • app directory (unstable)
 • advanced redirects

Error: An unexpected error has occurred.

firebase-debug.log:

TypeError: Cannot read properties of null (reading 'toString')
    at ɵcodegenFunctionsDirectory ([...]\node_modules\firebase-tools\lib\frameworks\next\index.js:220:18)
    at async prepareFrameworks ([...]\node_modules\firebase-tools\lib\frameworks\index.js:305:84)
    at async deploy ([...]\node_modules\firebase-tools\lib\deploy\index.js:53:13)
[error] 
[error] Error: An unexpected error has occurred.
sanesanyo commented 1 year ago

@1nterfect0r Can you please try running it on the emulator & see which errors you get (do post them here if you need help) ? That is how I found the bugs & tried resolving them. I am sensing it has to do with some package version & it is clearly happening in the cloud functions.

tinkersprojects commented 1 year ago

sooo i think i know what is going on. its trying to run npm ls --omit=dev --all --json in a command line but the output is tooo large for the buffer. this makes the JSON parse fail.

i have got it working by removing const dependencyTree = JSON.parse((0, child_process_1.spawnSync)("npm", ["ls", "--omit=dev", "--all", "--json"], { cwd: sourceDir, }).stdout.toString()); and replacing it with const dependencyTree = JSON.parse(fs_1.readFileSync(sourceDir + '/package-lock.json', 'utf8'));

but now i'm getting Valid choices are: {"node": 10|12|14|16} soo need to fix that now

Edduard commented 1 year ago

Using Node 16 & firebase tools version 11.14.3

Had the same problem. Made it work but only with these versions while nothing else did.

hussein661 commented 1 year ago

I have the same error.

  • firebase-tools v11.19.0
  • Node.js v16.14.2

I tryed it also with firebase-tools v11.14.3.

It worked with with firebase-tools v11.18.0

Console:

firebase deploy
Detected a Next.js codebase. This is an experimental integration, proceed with caution.

warn  - You have enabled experimental feature (appDir) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

info  - Creating an optimized production build  
info  - Compiled successfully
info  - Linting and checking validity of types  
info  - Collecting page data  
info  - Generating static pages (9/9)
info  - Finalizing page optimization

[...]

Building a Cloud Function to run this application. This is needed due to:
 • app directory (unstable)
 • advanced redirects

Error: An unexpected error has occurred.

firebase-debug.log:

TypeError: Cannot read properties of null (reading 'toString')
    at ɵcodegenFunctionsDirectory ([...]\node_modules\firebase-tools\lib\frameworks\next\index.js:220:18)
    at async prepareFrameworks ([...]\node_modules\firebase-tools\lib\frameworks\index.js:305:84)
    at async deploy ([...]\node_modules\firebase-tools\lib\deploy\index.js:53:13)
[error] 
[error] Error: An unexpected error has occurred.

I have the same error too ! did you manage to fix it ?

Neutronas commented 1 year ago

I am having the same issues as @hussein661.

hussein661 commented 1 year ago

firebase-tools version to 11.14.3 worked for me $ npm i -g firebase-tools@11.14.3

1nterfect0r commented 1 year ago

@hussein661 @Neutronas @sanesanyo Unfortunately i was not available in the past few days.

With firebase-tools v11.18.0 i can start the emulator:

PS D:\Programming\selfTranscript> firebase emulators:start
i  emulators: Starting emulators: auth, functions, firestore, hosting, storage
Detected a Next.js codebase. This is an experimental integration, proceed with caution.

warn  - You have enabled experimental feature (appDir) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

event - compiled client and server successfully in 3.1s (236 modules)

removed 26 packages, and changed 1 package in 13s

22 packages are looking for funding
  run `npm fund` for details
!  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database, pubsub
+  functions: Using node@16 from host.
+  functions: Using node@16 from host.
!  functions: Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to D:\Dokumente\service_account.json. Non-emulated services will access production using these credentials. Be careful!
i  firestore: Firestore Emulator logging to firestore-debug.log
+  firestore: Firestore Emulator UI websocket is running on 9150.
i  hosting[...]: Serving hosting files from: hosting\public
+  hosting[...]: Local server: http://127.0.0.1:5000
i  ui: Emulator UI logging to ui-debug.log
i  functions: Watching "D:\Programming\selfTranscript\functions" for Cloud Functions...
+  functions: Loaded functions definitions from source: onFileCreation.
+  functions[europe-west1-onFileCreation]: storage function initialized.
i  functions: Watching "D:\Programming\selfTranscript\.firebase\...\functions" for Cloud Functions...
!  functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions@latest in your functions directory.
!  functions: Please note that there will be breaking changes when you upgrade.
+  functions: Loaded functions definitions from source: ssr.
+  functions[...]: http function initialized (...).

┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://127.0.0.1:4000/               │
└─────────────────────────────────────────────────────────────┘

┌────────────────┬────────────────┬─────────────────────────────────┐
│ Emulator       │ Host:Port      │ View in Emulator UI             │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Authentication │ 127.0.0.1:9099 │ http://127.0.0.1:4000/auth      │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Functions      │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Firestore      │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Hosting        │ 127.0.0.1:5000 │ n/a                             │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Storage        │ 127.0.0.1:9199 │ http://127.0.0.1:4000/storage   │
└────────────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at 127.0.0.1:4400
  Other reserved ports: 4500, 9150

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.

But after using the hosting emulator i get the error in the console:

wait  - compiling /(home)/page (client and server)...
error - ./app/globals.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[3].oneOf[11].use[2]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[3].oneOf[11].use[3]!./app/globals.css
TypeError: Cannot read properties of undefined (reading 'config')
TypeError: Cannot read properties of undefined (reading '')
    at resolveModuleMetaData (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:204:82)
    at serializeModuleReference (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1349:50)
    at resolveModelToJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1716:40)
    at Array.toJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1132:40)
    at stringify (<anonymous>)
    at processModelChunk (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:172:36)
    at retryTask (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1879:50)
    at performWork (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1917:33)
    at eval (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1308:40)
    at scheduleWork (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:52:25)
    at pingTask (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1307:29)
    at ping (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/server.browser.js:1320:40)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

In firebase-debug.log:

[debug] [2023-01-02T20:03:59.017Z] ----------------------------------------------------------------------
[debug] [2023-01-02T20:03:59.019Z] Command:       C:\Program Files\nodejs\node.exe C:\Users\...\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js emulators:start
[debug] [2023-01-02T20:03:59.019Z] CLI Version:   11.18.0
[debug] [2023-01-02T20:03:59.019Z] Platform:      win32
[debug] [2023-01-02T20:03:59.019Z] Node Version:  v16.14.2
[debug] [2023-01-02T20:03:59.023Z] Time:          Mon Jan 02 2023 21:03:59 GMT+0100 (Mitteleuropäische Normalzeit)
[debug] [2023-01-02T20:03:59.023Z] ----------------------------------------------------------------------
[debug] 
[debug] [2023-01-02T20:03:59.028Z] >>> [apiv2][query] GET https://firebase-public.firebaseio.com/cli.json [none]
[debug] [2023-01-02T20:03:59.124Z] > 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-01-02T20:03:59.125Z] > authorizing via signed-in user (...)
[debug] [2023-01-02T20:03:59.308Z] java version "19.0.1" 2022-10-18

[debug] [2023-01-02T20:03:59.309Z] Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

[debug] [2023-01-02T20:03:59.325Z] Parsed Java major version: 19
[info] i  emulators: Starting emulators: auth, functions, firestore, hosting, storage {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: auth, functions, firestore, hosting, storage"}}
[debug] [2023-01-02T20:03:59.348Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2023-01-02T20:03:59.348Z] [auth] Authentication Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2023-01-02T20:03:59.348Z] [firestore] Firestore Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2023-01-02T20:03:59.348Z] [firestore.websocket] websocket server for firestore only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2023-01-02T20:03:59.348Z] [hosting] Hosting Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2023-01-02T20:03:59.348Z] [storage] Storage Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2023-01-02T20:03:59.349Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000},{"address":"::1","family":"IPv6","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"auth":[{"address":"127.0.0.1","family":"IPv4","port":9099}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}],"hosting":[{"address":"127.0.0.1","family":"IPv4","port":5000}],"storage":[{"address":"127.0.0.1","family":"IPv4","port":9199}]},"metadata":{"message":"assigned listening specs for emulators"}}
[debug] [2023-01-02T20:03:59.359Z] [hub] writing locator at C:\Users\...\AppData\Local\Temp\hub-[projectId].json
[debug] [2023-01-02T20:03:59.372Z] > refreshing access token with scopes: []
[debug] [2023-01-02T20:03:59.373Z] >>> [apiv2][query] POST https://www.googleapis.com/oauth2/v3/token [none]
[debug] [2023-01-02T20:03:59.373Z] >>> [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[debug] [2023-01-02T20:03:59.499Z] <<< [apiv2][status] GET https://firebase-public.firebaseio.com/cli.json 200
[debug] [2023-01-02T20:03:59.499Z] <<< [apiv2][body] GET https://firebase-public.firebaseio.com/cli.json {"cloudBuildErrorAfter":1594252800000,"cloudBuildWarnAfter":1590019200000,"defaultNode10After":1594252800000,"minVersion":"3.0.5","node8DeploysDisabledAfter":1613390400000,"node8RuntimeDisabledAfter":1615809600000,"node8WarnAfter":1600128000000}
[debug] [2023-01-02T20:03:59.533Z] <<< [apiv2][status] POST https://www.googleapis.com/oauth2/v3/token 200
[debug] [2023-01-02T20:03:59.533Z] <<< [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[debug] [2023-01-02T20:03:59.542Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/[projectId] [none]
[debug] [2023-01-02T20:03:59.860Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/[projectId] 200
[debug] [2023-01-02T20:03:59.861Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/[projectId] {"projectId":"[projectId]","projectNumber":"180277674698","displayName":"Transcript","name":"projects/[projectId]","resources":{"hostingSite":"[projectId]","storageBucket":"[projectId].appspot.com","locationId":"europe-west"},"state":"ACTIVE","etag":"1_cdae29d6-a21f-4fdd-8027-b9a87a00a74e"}
[debug] [2023-01-02T20:04:02.988Z] >>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/[projectId]/sites pageToken=&pageSize=10
[debug] [2023-01-02T20:04:04.010Z] <<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/[projectId]/sites 200
[debug] [2023-01-02T20:04:04.010Z] <<< [apiv2][body] GET https://firebasehosting.googleapis.com/v1beta1/projects/[projectId]/sites {"sites":[{"name":"projects/[projectId]/sites/[projectId]","defaultUrl":"https://[projectId].web.app","appId":"1:180277674698:web:bb682763e410fd137e6a33","type":"DEFAULT_SITE"}]}
[debug] [2023-01-02T20:04:04.011Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/-/webApps/1:180277674698:web:bb682763e410fd137e6a33/config [none]
[debug] [2023-01-02T20:04:04.951Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/-/webApps/1:180277674698:web:bb682763e410fd137e6a33/config 200
[debug] [2023-01-02T20:04:04.951Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/-/webApps/1:180277674698:web:bb682763e410fd137e6a33/config {"projectId":"[projectId]","appId":"1:180277674698:web:bb682763e410fd137e6a33","storageBucket":"[projectId].appspot.com","locationId":"europe-west","apiKey":"AIzaSyDnDpgrttsGS5o1jtG3pfmUjsEilC-0h8E","authDomain":"[projectId].firebaseapp.com","messagingSenderId":"180277674698","measurementId":"G-G14MZHNS0C"}
[debug] [2023-01-02T20:04:26.664Z] [functions] Functions Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2023-01-02T20:04:26.664Z] [eventarc] Eventarc Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[debug] [2023-01-02T20:04:26.665Z] late-assigned ports for functions and eventarc emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000},{"address":"::1","family":"IPv6","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"auth":[{"address":"127.0.0.1","family":"IPv4","port":9099}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}],"hosting":[{"address":"127.0.0.1","family":"IPv4","port":5000}],"storage":[{"address":"127.0.0.1","family":"IPv4","port":9199}],"functions":[{"address":"127.0.0.1","family":"IPv4","port":5001}],"eventarc":[{"address":"127.0.0.1","family":"IPv4","port":9299}]},"metadata":{"message":"late-assigned ports for functions and eventarc emulators"}}
[warn] !  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database, pubsub {"metadata":{"emulator":{"name":"functions"},"message":"The following emulators are not running, calls to these services from the Functions emulator will affect production: \u001b[1mdatabase, pubsub\u001b[22m"}}
[info] +  functions: Using node@16 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node@16 from host."}}
[info] +  functions: Using node@16 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node@16 from host."}}
[warn] !  functions: Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to D:\Dokumente\service_account.json. Non-emulated services will access production using these credentials. Be careful! {"metadata":{"emulator":{"name":"functions"},"message":"Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to D:\\Dokumente\\service_account.json. Non-emulated services will access production using these credentials. Be careful!"}}
[debug] [2023-01-02T20:04:26.716Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/[projectId]/adminSdkConfig [none]
[debug] [2023-01-02T20:04:27.265Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/[projectId]/adminSdkConfig 200
[debug] [2023-01-02T20:04:27.266Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/[projectId]/adminSdkConfig {"projectId":"[projectId]","storageBucket":"[projectId].appspot.com","locationId":"europe-west"}
[debug] [2023-01-02T20:04:27.295Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[debug] [2023-01-02T20:04:27.295Z] Ignoring unsupported arg: single_project_mode_error {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: single_project_mode_error"}}
[debug] [2023-01-02T20:04:27.295Z] Starting Firestore Emulator with command {"binary":"java","args":["-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","C:\\Users\\...\\.cache\\firebase\\emulators\\cloud-firestore-emulator-v1.15.1.jar","--host","127.0.0.1","--port",8080,"--websocket_port",9150,"--project_id","[projectId]","--rules","D:\\Programming\\selfTranscript\\firestore.rules","--single_project_mode",true,"--functions_emulator","127.0.0.1:5001"],"optionalArgs":["port","webc...l_port","host","rules","websocket_port","functions_emulator","seed_from_export","project_id","single_project_mode"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Dgoogle.cloud_firestore.debug_log_level=FINE\",\"-Duser.language=en\",\"-jar\",\"C:\\\\Users\\\\...\\\\.cache\\\\firebase\\\\emulators\\\\cloud-firestore-emulator-v1.15.1.jar\",\"--host\",\"127.0.0.1\",\"--port\",8080,\"--websocket_port\",9150,\"--project_id\",\"[projectId]\",\"--rules\",\"D:\\\\Programming\\\\selfTranscript\\\\firestore.rules\",\"--single_project_mode\",true,\"--functions_emulator\",\"127.0.0.1:5001\"],\"optionalArgs\":[\"port\",\"webc...l_port\",\"host\",\"rules\",\"websocket_port\",\"functions_emulator\",\"seed_from_export\",\"project_id\",\"single_project_mode\"],\"joinArgs\":false}"}}
[info] i  firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[info] +  firestore: Firestore Emulator UI websocket is running on 9150. {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator UI websocket is running on 9150."}}
[debug] [2023-01-02T20:04:36.798Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"storage"},"message":"Ignoring unsupported arg: port"}}
[debug] [2023-01-02T20:04:37.945Z] Temp file directory for storage emulator: C:\Users\...\AppData\Local\Temp/firebase/storage/blobs {"metadata":{"emulator":{"name":"storage"},"message":"Temp file directory for storage emulator: C:\\Users\\...\\AppData\\Local\\Temp/firebase/storage/blobs"}}
[debug] [2023-01-02T20:04:37.952Z] >>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/[projectId]/sites 
[debug] [2023-01-02T20:04:38.866Z] <<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/[projectId]/sites 200
[debug] [2023-01-02T20:04:38.866Z] <<< [apiv2][body] GET https://firebasehosting.googleapis.com/v1beta1/projects/[projectId]/sites {"sites":[{"name":"projects/[projectId]/sites/[projectId]","defaultUrl":"https://[projectId].web.app","appId":"1:180277674698:web:bb682763e410fd137e6a33","type":"DEFAULT_SITE"}]}
[debug] [2023-01-02T20:04:38.866Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/[projectId]/webApps/1:180277674698:web:bb682763e410fd137e6a33/config [none]
[debug] [2023-01-02T20:04:39.821Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/[projectId]/webApps/1:180277674698:web:bb682763e410fd137e6a33/config 200
[debug] [2023-01-02T20:04:39.821Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/[projectId]/webApps/1:180277674698:web:bb682763e410fd137e6a33/config {"projectId":"[projectId]","appId":"1:180277674698:web:bb682763e410fd137e6a33","storageBucket":"[projectId].appspot.com","locationId":"europe-west","apiKey":"AIzaSyDnDpgrttsGS5o1jtG3pfmUjsEilC-0h8E","authDomain":"[projectId].firebaseapp.com","messagingSenderId":"180277674698","measurementId":"G-G14MZHNS0C"}
[info] i  hosting[[projectId]]: Serving hosting files from: hosting\public {"metadata":{"emulator":{"name":"hosting"},"message":"Serving hosting files from: \u001b[1mhosting\\public\u001b[22m"}}
[info] +  hosting[[projectId]]: Local server: http://127.0.0.1:5000 {"metadata":{"emulator":{"name":"hosting"},"message":"Local server: \u001b[4m\u001b[1mhttp://127.0.0.1:5000\u001b[22m\u001b[24m"}}
[debug] [2023-01-02T20:04:39.858Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[debug] [2023-01-02T20:04:39.859Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[debug] [2023-01-02T20:04:39.859Z] Starting Emulator UI with command {"binary":"node","args":["C:\\Users\\...\\.cache\\firebase\\emulators\\ui-v1.11.1\\server\\server.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {\"binary\":\"node\",\"args\":[\"C:\\\\Users\\\\...\\\\.cache\\\\firebase\\\\emulators\\\\ui-v1.11.1\\\\server\\\\server.js\"],\"optionalArgs\":[],\"joinArgs\":false}"}}
[info] i  ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[debug] [2023-01-02T20:04:40.023Z] Web / API server started at 127.0.0.1:4000
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at 127.0.0.1:4000\n"}}
[debug] [2023-01-02T20:04:40.023Z] Web / API server started at ::1:4000
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at ::1:4000\n"}}
[info] i  functions: Watching "D:\Programming\selfTranscript\functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching \"D:\\Programming\\selfTranscript\\functions\" for Cloud Functions..."}}
[debug] [2023-01-02T20:04:40.134Z] Validating nodejs source
[debug] [2023-01-02T20:04:43.305Z] > [functions] package.json contents: {
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "build:watch": "tsc --watch",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "@google-cloud/speech": "^5.1.0",
    "firebase-admin": "^10.0.2",
    "firebase-functions": "^4.1.1"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.25.4",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^4.5.4"
  },
  "private": true
}
[debug] [2023-01-02T20:04:43.305Z] Building nodejs source
[debug] [2023-01-02T20:04:43.305Z] Analyzing nodejs backend spec
[debug] [2023-01-02T20:04:43.307Z] Could not find functions.yaml. Must use http discovery
[debug] [2023-01-02T20:04:43.754Z] Serving at port 9005

[debug] [2023-01-02T20:04:44.638Z] Got response from /__/functions.yaml {"endpoints":{"onFileCreation":{"platform":"gcfv1","availableMemoryMb":null,"timeoutSeconds":null,"minInstances":null,"maxInstances":null,"ingressSettings":null,"serviceAccountEmail":null,"vpc":null,"region":["europe-west1"],"eventTrigger":{"eventType":"google.storage.object.finalize","eventFilters":{"resource":"projects/_/buckets/[projectId].appspot.com"},"retry":false},"labels":{},"entryPoint":"onFileCreation"}},"specVersion":"v1alpha1","requiredAPIs":[]}
[debug] [2023-01-02T20:04:44.645Z] shutdown requested via /__/quitquitquit

[info] +  functions: Loaded functions definitions from source: onFileCreation. {"metadata":{"emulator":{"name":"functions"},"message":"Loaded functions definitions from source: onFileCreation."}}
[debug] [2023-01-02T20:04:44.661Z] addStorageTrigger {"eventTrigger":{"eventType":"google.storage.object.finalize","resource":"projects/_/buckets/[projectId].appspot.com"}}
[info] +  functions[europe-west1-onFileCreation]: storage function initialized. {"metadata":{"emulator":{"name":"functions"},"message":"\u001b[1mstorage\u001b[22m function initialized."}}
[info] i  functions: Watching "D:\Programming\selfTranscript\.firebase\[projectId]\functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching \"D:\\Programming\\selfTranscript\\.firebase\\[projectId]\\functions\" for Cloud Functions..."}}
[debug] [2023-01-02T20:04:44.664Z] Validating nodejs source
[warn] !  functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions@latest in your functions directory. 
[warn] !  functions: Please note that there will be breaking changes when you upgrade. 
[debug] [2023-01-02T20:04:47.479Z] > [functions] package.json contents: {
  "main": "server.js",
  "dependencies": {
    "firebase-frameworks": "^0.6.0",
    "firebase-functions": "^3.23.0",
    "firebase-admin": "^11.0.1"
  },
  "engines": {
    "node": "16"
  }
}
[debug] [2023-01-02T20:04:47.479Z] Building nodejs source
[debug] [2023-01-02T20:04:47.479Z] Analyzing nodejs backend spec
[debug] [2023-01-02T20:04:47.490Z] Found functions.yaml. Got spec: {
  "endpoints": {
    "ssr[projectId]": {
      "platform": "gcfv2",
      "region": [
        "us-central1"
      ],
      "labels": {},
      "httpsTrigger": {},
      "entryPoint": "ssr"
    }
  },
  "specVersion": "v1alpha1",
  "requiredAPIs": []
}
[info] +  functions: Loaded functions definitions from source: ssr. {"metadata":{"emulator":{"name":"functions"},"message":"Loaded functions definitions from source: ssr."}}
[info] +  functions[us-central1-ssr[projectId]]: http function initialized (http://127.0.0.1:5001/[projectId]/us-central1/ssr[projectId]). {"metadata":{"emulator":{"name":"functions"},"message":"\u001b[1mhttp\u001b[22m function initialized (http://127.0.0.1:5001/[projectId]/us-central1/ssr[projectId])."}}
[info] 
┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://127.0.0.1:4000/               │
└─────────────────────────────────────────────────────────────┘

┌────────────────┬────────────────┬─────────────────────────────────┐
│ Emulator       │ Host:Port      │ View in Emulator UI             │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Authentication │ 127.0.0.1:9099 │ http://127.0.0.1:4000/auth      │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Functions      │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Firestore      │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Hosting        │ 127.0.0.1:5000 │ n/a                             │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Storage        │ 127.0.0.1:9199 │ http://127.0.0.1:4000/storage   │
└────────────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at 127.0.0.1:4400
  Other reserved ports: 4500, 9150

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.

[info] i  hosting: 127.0.0.1 - - [02/Jan/2023:20:05:35 +0000] "GET / HTTP/1.1" 200 - "http://127.0.0.1:4000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" {"metadata":{"emulator":{"name":"hosting"},"message":"127.0.0.1 - - [02/Jan/2023:20:05:35 +0000] \"GET / HTTP/1.1\" 200 - \"http://127.0.0.1:4000/\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36\""}}
[info] i  hosting: 127.0.0.1 - - [02/Jan/2023:20:05:35 +0000] "GET /_next/static/chunks/webpack.js HTTP/1.1" 200 - "http://127.0.0.1:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" {"metadata":{"emulator":{"name":"hosting"},"message":"127.0.0.1 - - [02/Jan/2023:20:05:35 +0000] \"GET /_next/static/chunks/webpack.js HTTP/1.1\" 200 - \"http://127.0.0.1:5000/\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36\""}}
[info] i  hosting: 127.0.0.1 - - [02/Jan/2023:20:05:36 +0000] "GET /_next/static/chunks/main-app.js HTTP/1.1" 200 - "http://127.0.0.1:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" {"metadata":{"emulator":{"name":"hosting"},"message":"127.0.0.1 - - [02/Jan/2023:20:05:36 +0000] \"GET /_next/static/chunks/main-app.js HTTP/1.1\" 200 - \"http://127.0.0.1:5000/\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36\""}}
1nterfect0r commented 1 year ago

And I don't understand why there is the following output:

[warn] !  functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions@latest in your functions directory. 
[warn] !  functions: Please note that there will be breaking changes when you upgrade. 
[debug] [2023-01-02T20:04:47.479Z] > [functions] package.json contents: {
  "main": "server.js",
  "dependencies": {
    "firebase-frameworks": "^0.6.0",
    "firebase-functions": "^3.23.0",
    "firebase-admin": "^11.0.1"
  },
  "engines": {
    "node": "16"
  }
}

The package.json content in the functions dir is:

{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "build:watch": "tsc --watch",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "@google-cloud/speech": "^5.1.0",
    "firebase-admin": "^10.0.2",
    "firebase-functions": "^4.1.1"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.25.4",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^4.5.4"
  },
  "private": true
}

Maybe there is the reason for the error @sanesanyo

sanesanyo commented 1 year ago

@1nterfect0r The function directory it is referring to is in .firebase folder basically where it is deploying the NextJS app. Its configuration is different from firebase functions directory. This had me confused as well. Like I said before me, I had issues with every other firebase-tools version except the one I mentioned before. I do not think this has to do with the package versions. It seems all the emulators are working except hosting where this seems to be the error: "TypeError: Cannot read properties of undefined (reading 'config')". My sense is that may be it is your nextjs config file that is causing the issue. Not sure. Sorry in case I cannot be of so much help as I am having a stressful day. Trying to debug a Firebase plugin issue which is I cannot fix. The plugin works in one project but is throwing error in another.

sewonist commented 1 year ago

I have same error. In my case 11.18.0 work for me.

$ npm i -g firebase-tools@11.18.0

sanesanyo commented 1 year ago

Now I am getting another issue. I am trying to serve internationalised versions of my website i.e. in different languages than English & when I deploy the website, no root route is being served only locale routes are being served. When I run localhost, everything works as it is supposed to. I cannot find any documentation whatsoever for this. Only thing I found was a stackoverflow post with the same problem but no answer. I am starting to get fed up of this.

davidrayc commented 1 year ago

Don't use Next 13 with the latest firebase-tools or else you'll definitely get this issue. I got this issue right after I upgraded both to latest

If you want to use Next 13, you need to downgrade to 11.18.0 or lower. This is what I did for my current project. Thanks @hussein661 and @sewonist for the tip!

If you want firebase tools >=11.19.0, go back to Next 12.

sanesanyo commented 1 year ago

@davidrayc I am guessing you talk about just Next JS deployment or does that also fix the internationalisation issue that I raised before? Lately I am really get fed up of Firebase. Support from Firebase is also non existent when you raise these bugs. Only fellow developers are helping each other out. I do not get it. Firebase is supposed to be very developer friendly.

MarcosNotch commented 1 year ago

If you want to deploy next js 13 without making 1000 of configurations and not get fed up, I would recommend use AWS Amplify , its has all the firebase features but without so many bugs

sanesanyo commented 1 year ago

@MarcosNotch But now I am already stuck with Firebase and do not want to reconfigure everything :(. May be for next project. Thanks for the tip. I am mostly fed up of no support than the bugs. I am really shocked how little to no support coming from Firebase team.

davidrayc commented 1 year ago

Agree with @MarcosNotch 101%. I have Next apps deployed on both amplify and firebase. Only reason I use firebase is because of client requirements. If you have a choice, choose amplify for everything, not just next apps. Amplify is soooo far ahead of the game, and also AWS for that matter. Sorry Google :v:

sanesanyo commented 1 year ago

Thanks @davidrayc @MarcosNotch. I will check AWS Amplify out. Unfortunately I am currently running Web Development as a hobby and thus just do not have enough time to delve into a new ecosystem every week :(, so for now I will try to find a solution for these issues. Although I must say that for future projects, I am most likely not using Firebase. The developer support is what is annoying me the most. Almost none.

MiftahClassifieds commented 1 year ago

Hi fighters, i have same issue these days with firebase-tools versions last.I have many ideas now and im disturbing if i had to swotch to amplify or just waiting firebase team to fix the bugs.the probleb is that i use pure fire base products :auth, storage, realtime databse functions , hosting.. i im still hold on and writng this message to know what id the good suggestion for that issue .please if any one find out or fixed the problem to tell us .thanks in advance

MiftahClassifieds commented 1 year ago

My project Nextjs latest contains some dynamic pages [pid].js .If i use firebase-tools 11.18.0 as suggested before an other bug pop out from firebase-tools dependencies : like json return null cannot red undefined string .... and so on I think now like the problem comes from incompatible versions between npm, node.js, firebase-tools and nextjs im gonna to try now next12 instead of 13 . hard luck guys

sanesanyo commented 1 year ago

@MiftahClassifieds I have similar problem. I am just stuck as I am using other firebase services as well as GCP services and migrating to AWS Amplify will cause a lot more pain in short term and therefore wishful thinking that Firebase fixes these bugs. But so far have not heard a single thing from Firebase directly, only developers trying to help developers. I do not get it. I have already raised issues in 3 different threads and got nothing so far. I solved the first bug, now I am stuck with next-translate issue. Everything works on local host & when I deploy, no files are served or in some cases only locale routes. Now I am not able to push my changes from last 1 week. Enough of my rants :), I wish you all the best in sorting out the bugs and hoping some of the Firebase overlords hear us & try to help us out.

MiftahClassifieds commented 1 year ago

Resolved! while waiting for the firebase team to sync their latest firebase-tools 11.20.0 with Next13: Requirements are collected in this json object: miftah.json: `{ "nodejs": "16.14.2", "npm": "8.19.3", "firebase-tools": "11.14.3",

"scripts": { "firebase-tools": "npm i -g firebase-tools@11.18.0 --exact", "next": "npm install next@12.1.4 react@17.0.2 react-dom@17.0.2 --exact" } } 1- create next project using :npm create next-app 2- delete package.lock.json and all dependencies related with next13 like font 3- run commands: npm i -g firebase-tools@11.18.0 --exact and then npm install next@12.1.4 react@17.0.2 react-dom@17.0.2 --exact` 4- init firebase and deploy by these steps you can deploy either static and dynamic pages [pid].js. tested! and You are done congratulations 👍 Please don't miss the versions above 💯

sanesanyo commented 1 year ago

@MiftahClassifieds Great to hear that. For me, it is also working with Next 13 with Firebase Tool 11.18.1. Where I am having issues now is with internationalisation i.e. I am using next-translate to serve pages in different languages and when I deploy the app the root route is not getting served. Only locale routes are getting served. I am sensing it has to do with some redirect rules as pages are being served from the cdn & if it does not find anything in the root, it just throws error where as in it should be serving the locale page if any of the browser has a matching locale otherwise it should be serving the default language. In my case, it is just throwing an error when I call the root page. Everyhing works as it should on local host as well as firebase serve.

Can you please share your firebase.json config? May be it has to do with that.

MiftahClassifieds commented 1 year ago

Hi, @sanesanyo , I think The issue is not with firebase.json .There is a mismatch between these releases (firebase-tools 11.20.0 latest and next13 lates) By now i will work on internationalisation issue because my have 3 languages too good luck

sanesanyo commented 1 year ago

@MiftahClassifieds Thanks. So if I understood you correctly. If I use Next JS 12, I will not this issue I am facing? Can you please confirm? Thanks a lot in advance.

MiftahClassifieds commented 1 year ago

Oh my god, after about 10 days of stress. I got it!! @sanesanyo yes sir! internationalisation works too all the requirements are collected in miftah.json: ` { "nodejs": "16.14.2", "npm": "8.19.3", "firebase-tools": "11.14.3",

"scripts": { "firebase-tools": "npm i -g firebase-tools@11.18.0 --exact", "next": "npm install next@12.1.4 react@17.0.2 react-dom@17.0.2 --exact" } ` just try next12 because the last release is not not taken in consideration by latest firebase-tools! good night

sanesanyo commented 1 year ago

@MiftahClassifieds I tried but still get the same issues. Only locale routes are working & root route is failing. Are you using next-translate package as well? I have spent far too much time to fix this now. Someone from Firebase gotta help.

MiftahClassifieds commented 1 year ago

@sanesanyo If you you could provide your firebase-debug.log plz

sanesanyo commented 1 year ago

@MiftahClassifieds So I have two locales: en and de. And when I deploy locally, when user has anything that is not "de" locale, "en" locale is served. So when someone goes to the root page, they will get pages in "en" if their locale is not "de". But this behaviour changes when I deploy in production i.e. when someone goes to the root page there is an error and only /en and /de routes work. On local /, /en, /de routes work. The app is able to deploy without any errors, only when it comes to serving the pages, the behaviour is production is very different from local deploy. I looked up in the cloud run logs and found the following error: Error: Cannot find module '/workspace/i18n' 2023-01-11 01:09:51.836 CET Require stack: 2023-01-11 01:09:51.836 CET

I am really getting frustrated. No help from Firebase and I am pretty sure this has to do something with the container image deployed on Cloud Run.

MiftahClassifieds commented 1 year ago

Hi @sanesanyo , if you use these links: https://www.miftahonline.com/privacy_policy https://www.miftahonline.com/en/privacy_policy https://www.miftahonline.com/ar/privacy_policy You will see that I deployed next 12 app with Translations without any problems .Im stacking now when I use firebase sdk like realtime, storage, auth... if i remove firebase 9.15.0 and (removing lock files of either project and node_modules to assuring sync between package.json and lock file.json) all work well with this config edited!!! "myconfig": { "i18next": "^17.0.2", "next": "^12.1.4", "next-i18next": "^12.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", "nodejs": "16.14.2", "npm": "8.19.3", "firebase-tools": "11.14.3", } make sure you are removing firebase sdk 9.15.0 (just to testing) and cleaning up your project (run npm ci shouldn't give any error) and tell me what you have . good chance

MiftahClassifieds commented 1 year ago

@sanesanyo .If i understood you you deployed your app successfully! but it can serve only default locale in production? tell me please if you use firebase sdk web and what version did you use ? good luck

sanesanyo commented 1 year ago

Hi @MiftahClassifieds yes, the app is successfully deployed but root routes are not getting served. I realized I am using "next-translate" package and you are using "next-i18next" so may be i switch to your package, things might work? I am using firebase-tools 11.18.0. I will let you know in case using this difference package helps out.

MiftahClassifieds commented 1 year ago

@sanesanyo firebase 9.9.0 works!! I m pretty happy ! good luck for you too

MiftahClassifieds commented 1 year ago

So the final config would be: "myconfig": { "i18next": "^17.0.2", "next": "^12.1.4", "next-i18next": "^12.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", "nodejs": "16.14.2", "npm": "8.19.3", "firebase-tools": "11.14.3","firebase": 9.9.0 } if any one still stacked with this

sanesanyo commented 1 year ago

@MiftahClassifieds Thanks. Can you please also share your firebase.json? Just to make sure I am not Missing something.

MiftahClassifieds commented 1 year ago

@sanesanyo You are welcome package.json: { "name": "s_miftahonline", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "firebase": "^9.9.0", "i18next": "^17.0.2", "next": "^12.1.4", "next-i18next": "^12.0.0", "react": "^17.0.2", "react-dom": "^17.0.2" } } next.config.js: `` const {i18n} = require("./next-i18next.config") const nextConfig = { i18n, reactStrictMode: true, }

module.exports = nextConfig `` next-i18next.config.js:

module.exports = { i18n: { locales: ["fr", "ar", "en"], defaultLocale: "fr", localeDetection: false, // localePath: path.resolve("./public/locales"), } }

sanesanyo commented 1 year ago

@MiftahClassifieds Thanks but I was asking for firebase.json