Coder Social home page Coder Social logo

Comments (6)

danielnichols avatar danielnichols commented on May 19, 2024 3

I'm on Windows and had issues with this as well, but I fixed it by using the cross-env package. I changed the serve script in package.json to "cross-env NODE_ENV=production firebase serve --only functions,hosting", and I changed build-app to "cross-env NODE_ENV=production next build \"src/app\"". Now I don't get any issues with build, serve or deploy

edit: It seems that the code I deploy doesn't actually work, probably because the Next compiler is writing some file paths with \ separators instead of /, which is not supported by Firebase.

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

It would be interesting to see how this functions on Windows given the update to firebase-tools and the serve command. Could the next Windows user to come across this please let us all know? Cheers in advance!

from firebase-functions-next-example.

jowo-io avatar jowo-io commented on May 19, 2024

Was recieving the following error:

!  functions[app-next(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Code in file index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: Error: Could not find a valid build in the '/user_code/next' directory! Try building your app with 'next build' before starting the server.
    at Server.readBuildId (/user_code/node_modules/next/dist/server/next-server.js:783:15)
    at new Server (/user_code/node_modules/next/dist/server/next-server.js:80:25)
    at module.exports (/user_code/node_modules/next/dist/server/next.js:6:10)
    at Object.<anonymous> (/user_code/app/app.js:17:31)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)

when deploying, after adding cross-env as Hexellate suggested the deploy worked.
But still currently having issues seeing the output on the firebaseapp.

it just shows Internal Server Error

will report back

from firebase-functions-next-example.

jowo-io avatar jowo-io commented on May 19, 2024

So looking at the firebase logs, i saw this error:


{ Error: Cannot find module '/user_code/next/server/static\6kN8iFmiMafh42XoG7uzi\pages\index.js
at Function.Module._resolveFilename (module.js:476:15
at Function.Module._load (module.js:424:25
at Module.require (module.js:504:17
at require (internal/module.js:20:19
at _callee$ (/user_code/node_modules/next/dist/server/require.js:85:46
...
...
'MODULE_NOT_FOUND' } 

After noticing the paths using \ I tried a find and replace on the dist folder and replaced all \ with /'s

and then disabled the predeploy key in firebase.json, then re-deployed:
screenshot 51

and it worked!

will look into how to make the build output /'s instead of \'s

from firebase-functions-next-example.

jowo-io avatar jowo-io commented on May 19, 2024

looks like the issue was fixed in next 7.0.3
vercel/next.js#4920
so upgrading to 7.0.3 should fix. so if using Windows, just remember to add cross-env as mentioned above

from firebase-functions-next-example.

jthegedus avatar jthegedus commented on May 19, 2024

Hi all, sorry for not getting back to you sooner. I am deprecating this example in favor of another approach, which can be found in this repo (https://github.com/jthegedus/firebase-gcp-examples/tree/master/functions-nextjs). Hopefully it is somewhat more windows friendly. I am back on Windows, had used WSL2 in the past but found it slow, so am now testing out the new VSCode Online - https://visualstudio.microsoft.com/services/visual-studio-online/

I've been very busy the last few months and getting back into the swing of OSS and writing so if you are having issues I will truly try and be more prompt next time. Cheers.

from firebase-functions-next-example.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.