Skip to content

Running firebase deploy for Next Js  #5661

Closed

Description

@friday-sds

[REQUIRED] Environment info

firebase-tools: 11.25.2
Node Js: 16.14.2

Platform: macOS (m1 / arm64)

[REQUIRED] Steps to reproduce

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 ..%`

Next Js Config
`/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}

module.exports = nextConfig`

Activity

  1. google-oss-bot commented on Apr 5, 2023

    @google-oss-bot
    Collaborator

    This issue does not seem to follow the issue template. Make sure you provide all the required information.

  2. jamesdaniels commented on Apr 5, 2023

    @jamesdaniels
    Contributor

    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.

  3. friday-sds commented on Apr 6, 2023

    @friday-sds
    Author

    My guess is it has something to do with the api routes for app directory

  4. jamesdaniels commented on Apr 6, 2023

    @jamesdaniels
    Contributor

    @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.

  5. PanosParalakis commented on Apr 11, 2023

    @PanosParalakis

    @jamesdaniels any updates regarding this issue ?

  6. jamesdaniels commented on Apr 14, 2023

    @jamesdaniels
    Contributor

    @friday-sds @PanosParalakis mind giving the fixes a spin npm i -g github:firebase/firebase-tools#frameworksCTA
    Let me know how it goes

  7. PanosParalakis commented on Apr 17, 2023

    @PanosParalakis

    @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

  8. PanosParalakis commented on Apr 25, 2023

    @PanosParalakis

    Hi @jamesdaniels did you manage to look at this issue further? TY!

  9. joenewbry commented on Apr 26, 2023

    @joenewbry

    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)

  10. joenewbry commented on Apr 26, 2023

    @joenewbry

    @jamesdaniels trying out the branch you mentioned and I'll let you know how the deploy goes

  11. joenewbry commented on Apr 26, 2023

    @joenewbry

    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 }

  12. joenewbry commented on Apr 26, 2023

    @joenewbry

    from the prerenderedManifest it looks like the dataRoutes for favicon.ico is also null

    '/favicon.ico': { initialHeaders: [Object], initialRevalidateSeconds: false, srcRoute: '/favicon.ico', dataRoute: null

  13. joenewbry commented on Apr 26, 2023

    @joenewbry

    @jamesdaniels the branch worked for me! 🙌 thanks!

  14. joenewbry commented on Apr 26, 2023

    @joenewbry

    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.

  15. PanosParalakis commented on Apr 27, 2023

    @PanosParalakis

    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

  16. added a commit that references this issue on May 5, 2023
    82c81a9
  17. added a commit that references this issue on May 22, 2023
    95b361f
  18. added a commit that references this issue on Mar 23, 2024
    e5981f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions