You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Try following this doc for a basic next js 13 (appDir) project
[REQUIRED] Expected behavior
Your app should deploy in firebase hosting and you will have an url
[REQUIRED] Actual behavior
Getting this error
`Building a Cloud Function to run this application. This is needed due to:
• app directory (unstable)
info - Creating an optimized production build ...[2023-04-05T12:05:37.437Z] TypeError: Cannot read properties of null (reading 'endsWith')
at ɵcodegenPublicDirectory (/Users/xyz/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/frameworks/next/index.js:206:56)
at async prepareFrameworks (/Users/xyz/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/frameworks/index.js:269:13)
at async deploy (/Users/xyz/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/index.js:53:13)
Error: An unexpected error has occurred.
info - Creating an optimized production build ..%`
My guess is NextJS altered one of the manifest files (for the app directory) that we're peaking in to export static content for the CDN.
That line of code we're testing whether we're dealing with a React Server Component, so we can copy from the correct directory. I'll take a peek, thanks for the report.
@jamesdaniels I think it tries to build and no matter how many dependencies I install globally l keep getting errors when trying to install. I had no issues installing v11.27.0 on which the issue still persists.
❯ npm i -g github:firebase/firebase-tools#frameworksCTA npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs npm WARN deprecated [email protected]: this library is no longer supported npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 npm ERR! code 127 npm ERR! git dep preparation failed npm ERR! command /.nvm/versions/node/v18.15.0/bin/node /.nvm/versions/node/v18.15.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run npm ERR! npm WARN using --force Recommended protections disabled. npm ERR! npm ERR! code 127 npm ERR! npm ERR! path /.npm/_cacache/tmp/git-clonekmnjgl npm ERR! npm ERR! command failed npm ERR! npm ERR! command sh -c npm run clean && npm run build:publish npm ERR! npm ERR! > [email protected] clean npm ERR! npm ERR! > rimraf lib dev npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! > [email protected] build:publish npm ERR! npm ERR! > tsc --build tsconfig.publish.json && npm run copyfiles npm ERR! npm ERR! npm WARN using --force Recommended protections disabled. npm ERR! npm ERR! npm WARN using --force Recommended protections disabled. npm ERR! npm ERR! sh: tsc: command not found
And that's from looking at the firebase-debug.log line: TypeError: Cannot read properties of null (reading 'endsWith') at ɵcodegenPublicDirectory (/usr/local/lib/node_modules/firebase-tools/lib/frameworks/next/index.js:206:56)
Also kinda dumb question but I'm wondering what the difference between using npm i -g github:firebase/firebase-tools#frameworksCTA and cloning the repository locally and running npm i and npm link?
I wasn't able to use npm i -g github:firebase/firebase-tools#frameworksCTA. A bunch of things broke for me when I tried that but the cloning locally and then installing method worked great!
From npm i joe@joes-mbp my-app % npm i -g github:firebase/firebase-tools#frameworksCTA npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs npm WARN deprecated [email protected]: this library is no longer supported npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 npm ERR! code 1 npm ERR! git dep preparation failed npm ERR! command /Users/joe/.nvm/versions/node/v16.20.0/bin/node /Users/joe/.nvm/versions/node/v16.20.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/joe/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run npm ERR! npm WARN using --force Recommended protections disabled. npm ERR! npm ERR! code 1 npm ERR! npm ERR! path /Users/joe/.npm/_cacache/tmp/git-cloneHifUji npm ERR! npm ERR! command failed npm ERR! npm ERR! command sh -c -- npm run clean && npm run build:publish npm ERR! npm ERR! > [email protected] clean npm ERR! npm ERR! > rimraf lib dev npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! > [email protected] build:publish npm ERR! npm ERR! > tsc --build tsconfig.publish.json && npm run copyfiles npm ERR! npm ERR! npm ERR! npm ERR! src/configstore.ts(1,30): error TS2307: Cannot find module 'configstore' or its corresponding type declarations.
I wasn't able to use npm i -g github:firebase/firebase-tools#frameworksCTA. A bunch of things broke for me when I tried that but the cloning locally and then installing method worked great!
.`
Thanks for that @joenewbry, I was having similar issue, I did not try cloning but I ll give it a go
Activity
google-oss-bot commentedon Apr 5, 2023
This issue does not seem to follow the issue template. Make sure you provide all the required information.
jamesdaniels commentedon Apr 5, 2023
My guess is NextJS altered one of the manifest files (for the app directory) that we're peaking in to export static content for the CDN.
That line of code we're testing whether we're dealing with a React Server Component, so we can copy from the correct directory. I'll take a peek, thanks for the report.
friday-sds commentedon Apr 6, 2023
My guess is it has something to do with the
apiroutes for app directoryjamesdaniels commentedon Apr 6, 2023
@friday-sds that would make sense, as it's app directory & in that manifest but not an RSC with json that needs rehydration. I'll see if I can repro.
PanosParalakis commentedon Apr 11, 2023
@jamesdaniels any updates regarding this issue ?
jamesdaniels commentedon Apr 14, 2023
@friday-sds @PanosParalakis mind giving the fixes a spin
npm i -g github:firebase/firebase-tools#frameworksCTALet me know how it goes
PanosParalakis commentedon Apr 17, 2023
@jamesdaniels I think it tries to build and no matter how many dependencies I install globally l keep getting errors when trying to install. I had no issues installing v11.27.0 on which the issue still persists.
❯ npm i -g github:firebase/firebase-tools#frameworksCTA npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs npm WARN deprecated [email protected]: this library is no longer supported npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 npm ERR! code 127 npm ERR! git dep preparation failed npm ERR! command /.nvm/versions/node/v18.15.0/bin/node /.nvm/versions/node/v18.15.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run npm ERR! npm WARN using --force Recommended protections disabled. npm ERR! npm ERR! code 127 npm ERR! npm ERR! path /.npm/_cacache/tmp/git-clonekmnjgl npm ERR! npm ERR! command failed npm ERR! npm ERR! command sh -c npm run clean && npm run build:publish npm ERR! npm ERR! > [email protected] clean npm ERR! npm ERR! > rimraf lib dev npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! > [email protected] build:publish npm ERR! npm ERR! > tsc --build tsconfig.publish.json && npm run copyfiles npm ERR! npm ERR! npm WARN using --force Recommended protections disabled. npm ERR! npm ERR! npm WARN using --force Recommended protections disabled. npm ERR! npm ERR! sh: tsc: command not foundPanosParalakis commentedon Apr 25, 2023
Hi @jamesdaniels did you manage to look at this issue further? TY!
joenewbry commentedon Apr 26, 2023
Hi based on the logs for me. There's an error here:
const isReactServerComponent = route.dataRoute.endsWith(".rsc");And that's from looking at the firebase-debug.log line:
TypeError: Cannot read properties of null (reading 'endsWith') at ɵcodegenPublicDirectory (/usr/local/lib/node_modules/firebase-tools/lib/frameworks/next/index.js:206:56)joenewbry commentedon Apr 26, 2023
@jamesdaniels trying out the branch you mentioned and I'll let you know how the deploy goes
joenewbry commentedon Apr 26, 2023
Not sure if it's helpful. It looks like certain routes don't have a corresponding dataRoute.
{ initialRevalidateSeconds: false, srcRoute: '/admin', dataRoute: '/admin.rsc' } { initialRevalidateSeconds: false, srcRoute: '/signup', dataRoute: '/signup.rsc' } { initialRevalidateSeconds: false, srcRoute: '/signin', dataRoute: '/signin.rsc' } { initialHeaders: { 'content-type': 'text/plain;charset=UTF-8' }, initialRevalidateSeconds: false, srcRoute: '/api/hello', dataRoute: null }joenewbry commentedon Apr 26, 2023
from the prerenderedManifest it looks like the dataRoutes for favicon.ico is also null
'/favicon.ico': { initialHeaders: [Object], initialRevalidateSeconds: false, srcRoute: '/favicon.ico', dataRoute: nulljoenewbry commentedon Apr 26, 2023
@jamesdaniels the branch worked for me! 🙌 thanks!
joenewbry commentedon Apr 26, 2023
Also kinda dumb question but I'm wondering what the difference between using
npm i -g github:firebase/firebase-tools#frameworksCTAand cloning the repository locally and runningnpm iandnpm link?I wasn't able to use
npm i -g github:firebase/firebase-tools#frameworksCTA. A bunch of things broke for me when I tried that but the cloning locally and then installing method worked great!From npm i
joe@joes-mbp my-app % npm i -g github:firebase/firebase-tools#frameworksCTA npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs npm WARN deprecated [email protected]: this library is no longer supported npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 npm ERR! code 1 npm ERR! git dep preparation failed npm ERR! command /Users/joe/.nvm/versions/node/v16.20.0/bin/node /Users/joe/.nvm/versions/node/v16.20.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/joe/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run npm ERR! npm WARN using --force Recommended protections disabled. npm ERR! npm ERR! code 1 npm ERR! npm ERR! path /Users/joe/.npm/_cacache/tmp/git-cloneHifUji npm ERR! npm ERR! command failed npm ERR! npm ERR! command sh -c -- npm run clean && npm run build:publish npm ERR! npm ERR! > [email protected] clean npm ERR! npm ERR! > rimraf lib dev npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! > [email protected] build:publish npm ERR! npm ERR! > tsc --build tsconfig.publish.json && npm run copyfiles npm ERR! npm ERR! npm ERR! npm ERR! src/configstore.ts(1,30): error TS2307: Cannot find module 'configstore' or its corresponding type declarations.PanosParalakis commentedon Apr 27, 2023
Thanks for that @joenewbry, I was having similar issue, I did not try cloning but I ll give it a go
Handle NextJS 13.3 app directory (firebase#5691)
Handle NextJS 13.3 app directory (#5691)
Handle NextJS 13.3 app directory (firebase#5691)