vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.2k stars 26.75k forks source link

Can't deploy site to firebase using npm run build #58763

Open Vojteggg opened 10 months ago

Vojteggg commented 10 months ago

Link to the code that reproduces this issue

https://github.com/Vojteggg/CookBook

To Reproduce

I have the default next.js app, from the tutorial, and I want to host it on firebase, I did firebase init hosting, and everything worked, but then I wanted to add github in between, so I ran firebase init hosting:github, configured it with running the npm run build only. When the script starts running on github it gives me an error that the command next was not found. And yes, I installed specifically node, next using npm inside of the app folder. Also I tried removing the node_modules and adding it again, but nothing seem to work/nor change anything inside the app. The error: Run npm run build

build next build

sh: 1: next: not found Error: Process completed with exit code 127.

Also when tried running npx next run it gives this error: Invalid project directory provided, no such directory: app_folder/run

I want it to be hosted on Google as it is for a school project, and teacher wants it to be firebase.

Current vs. Expected behavior

Dropping weird errors, while it should just deploy the site, the rest of the script works all good.

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:42:42 PDT 2023; root:xnu-10002.1.13~1/RELEASE_X86_64
Binaries:
  Node: 21.1.0
  npm: 9.6.7
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.3
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Additional context

No response

Vojteggg commented 10 months ago

Also, when i try using the commands npm ci && npm run build it gives me weird error: Build error occurred

ReferenceError: window is not defined at getOrCreateDataLayer (file:///home/runner/work/CookBook/CookBook/node_modules/@firebase/analytics/dist/esm/index.esm2017.js:177:23) at factory (file:///home/runner/work/CookBook/CookBook/node_modules/@firebase/analytics/dist/esm/index.esm2017.js:1038:9) at Component.instanceFactory (file:///home/runner/work/CookBook/CookBook/node_modules/@firebase/analytics/dist/esm/index.esm2017.js:1245:16) at Provider.getOrInitializeService (file:///home/runner/work/CookBook/CookBook/node_modules/@firebase/component/dist/esm/index.esm2017.js:290:39) at Provider.initialize (file:///home/runner/work/CookBook/CookBook/node_modules/@firebase/component/dist/esm/index.esm2017.js:234:31) at initializeAnalytics (file:///home/runner/work/CookBook/CookBook/node_modules/@firebase/analytics/dist/esm/index.esm2017.js:1087:49) at getAnalytics (file:///home/runner/work/CookBook/CookBook/node_modules/@firebase/analytics/dist/esm/index.esm2017.js:1066:12) at /home/runner/work/CookBook/CookBook/.next/server/pages/index.js:1:1935 Error: Failed to collect page data for / at /home/runner/work/CookBook/CookBook/node_modules/next/dist/build/utils.js:1217:15 *** type: 'Error'


Error: Process completed with exit code 1.