terribleplan / next-cloudflare

A way to build next.js apps for cloudflare workers
MIT License
14 stars 1 forks source link

fails with vanilla create-next-app #1

Open wizzard0 opened 4 years ago

wizzard0 commented 4 years ago

following the quickstart, after building and linking, the build fails

C:\dev\2020\test-2-nextcf\next2\node_modules\next -> C:\Users\user\AppData\Local\nvs\node\10.15.3\x64\node_modules\next -> C:\dev\2020\test-2-nextcf\next.js\packages\next
PS C:\dev\2020\test-2-nextcf\next2> npx next build
internal/modules/cjs/loader.js:584
    throw err;
    ^

Error: Cannot find module './dist/server/config'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (C:\dev\2020\test-2-nextcf\next.js\packages\next-server\next-config.js:1:80)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
terribleplan commented 4 years ago

This project was based on version 8.x.x of next and changes some things pretty deep inside, I'm not sure what the interaction of create-next-app is with a custom/linked version of next. You may need to manually install create-next-app and link in the custom version of next.js. It may not actually be possible that since 9.x.x changed a lot of how the sub-packages are split (and create-next-app is now in-tree).

If I have some free time I might look into updating this fork for 9.x.x. If operating without SSR is acceptable you may want to look into cloudflare/wrangler to upload a static version of your site in the mean time.

It may be worth looking into things based on fab, which aims to unify serverless targets across a bunch of different frontend projects and some of the community there say they want to support SSR and static assets in workers + K/V. That was vaguely what this project was trying to push toward and next wasn't interested in.