bridge: Build fails with SSR turned off
Environment
- Operating System:
Linux - Node Version:
v14.18.0 - Nuxt Version:
2.16.0-27226092.034b9901 - Package Manager:
Yarn - Bundler:
Webpack - User Config:
ssr,buildModules - Runtime Modules:
- - Build Modules:
@nuxt/bridge@3.0.0-27234503.d5127e9
Describe the bug and expected behavior
nuxi build fails with ssr: false. Output:
start Building server... 00:26:02
ERROR Rollup error: Could not load .nuxt/dist/server/server.mjs (imported by node_modules/@nuxt/nitro/dist/runtime/app/render.mjs): ENOENT: no such file or directory, open '.nuxt/dist/server/server.mjs'
ERROR Nuxt Build Error: Could not load .nuxt/dist/server/server.mjs (imported by node_modules/@nuxt/nitro/dist/runtime/app/render.mjs): ENOENT: no such file or directory, open '.nuxt/dist/server/server.mjs'
Steps to reproduce
- Set
ssr: falseinnuxt.config.ts. - Run (
npx)nuxi buildin shell.
Additional context
My project doesn’t need SSR, but needs “runtime config” with environment variables injected by Node.js.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 65
- Comments: 92 (17 by maintainers)
Commits related to this issue
- Taken out ssr guard for building a server. Build now uses ssr setting from nuxt.config, default remains true. Fixes #886 — committed to blazmrak/framework by blazmrak 2 years ago
- fix(nuxt): disable nitro in production See workaround mentioned in https://github.com/nuxt/framework/issues/886. — committed to dargmuesli/jonas-thelemann by dargmuesli 2 years ago
- fix(nuxt): transpile bridge See a most likely related issue at https://github.com/nuxt/framework/issues/886. — committed to dargmuesli/jonas-thelemann by dargmuesli 2 years ago
- build(nuxt): add `build.transpile` option for `@nuxt/bridge` workaround for nuxt/bridge#27 — committed to nogic1008/nuxt-ts-template by nogic1008 2 years ago
- build(nuxt): add `build.transpile` option for `@nuxt/bridge` workaround for nuxt/bridge#27 — committed to nogic1008/nuxt-ts-template by nogic1008 2 years ago
you could turn off nitro temporary
any update on this?
I created a work a round, that makes it possible to build without using a fork:
This will put a file in the proper directory just before rollup needs it.
It’s not working atm
I always delete node_modules, package-lock and reinstall everything.
Apparently the recently launched version
3.0.0-27383827.b803fdbfixes the problem, but I still cannot build it withnitro.I think this issue should be reopened then.
I think @crazymind 's comment is totally related to this issue. It seems that disabling nitro is not even a temporary fix to this bug, because you will not be able to use nuxt properly…
New reproduction with the latest version of @nuxt/bridge (npm:@nuxt/bridge-edge@^3.0.0-27530716.c4f8671):
git clone git@github.com:HendrikJan/nuxt-bridge-error-demo.gitnpm installnpx nuxi buildThe problem is still there.
Confirm. Tested on 3.0.0-27495976.e31c604 And I also use Nuxt3 (without bridge), and seems there is no workaround for this case.
thanks bro, it works for me
@rodrigogs you can change node_module/…/bridge/vite/server.ts ssr:true to ssr:false and give it a try (the file looks the same as the one I linked in the comment above) @pi0 Would it make sense to replicate
ssr: ctx.nuxt.options.ssr ?? truein Bridge? I am fresh to Nuxt 3 and have no idea what needs to be replicated in Bridge and what doesn’t.to build your project first run
nuxi buildthennuxi generateand serve it with
nuxt startYeah, my pull request (#2191) doesn’t seem to have actually fixed this issue. It’s working in Nuxt’s
playgrounddirectory, but for some reason, if you actually create a project, Rollup still thinks it needs to import#build/dist/server/server.mjs.I hop fixing this bug be a priority for Nuxt team. I know you are busy on the Nuxt3 it self but as a matter of fact Vuetify is one of most popular component frameworks for Vue and they are so slow on migrating to Vue3. Me my self am trying to replace it with pure css frameworks like tailwind but until then it is not possible for me to switch to Nuxt3. Meanwhile i have to make the hole project ready for Vue3 and Nuxt3 and it is lots of work! so i choose bridge as the best migration option. but after #320 i kinda stuck!
Because of this bug I needed to disable nitro as well. Now running in to the next issue:
$fetch is not definedI read that:
Therefore I assume this will cause a chain reaction as $fetch will not be available and other libraries depending on it. I tried to install
ohmyfetchandnode-fetchmanually – no luck. Also tried to inject $fetch as a plugin – also no luck. Anyone an idea how to fix this?If anyone has the same problems (build success, but no entry point), here is script that generates
index.htmlfrom build result. Just run it from the root of the project (node generateIndexHtml.mjs):Guys, am I stupid or is there no reason for this line? Commenting it out builds the server and running it works, the only issue I have with it is that I lose the css from app.vue, which does not seem to get requested from the client.
If it’s already in version 3.0.0-27313139.1c88580, then it’s still not working.
Same error as before.
I can’t believe an empty file could solve this problem! Thanks a lot @rvmourik
I upgraded to 3.0.0-27530716.c4f8671 which should include that commit but I still get the exact same error… Am I missing something?
I hope so too. We are waiting for Vuetify 3 too before we can move to the real Nuxt 3 (really looking forward to that!). Currently using
nuxi devinstead ofnuxi buildbut that’s not a solution when our production goes live 🙃.This issue still exists. Disabling nitro for production fixes the issue.
Facing the same issue, followed the workaround given by disabling
nitroonly in production build(s)PS. Ignore the
export NODE_OPTIONSbit, I have to use it cause of Node v17.Now, Nitro works in
dev, but while bundling, it’s disabled 😄Any updates here? I’m trying on
v3.0.0-27394404.1672148, and build success but there is no entry point in.output/public/like index.html Nuxt3 project.What?
I have
ssr: falseinnuxt.config.js@rodrigogs it’s works, i made a mistake,
generatedir should be/dist,but i view in to/.nuxt/dist/. and thanks @AllInOneYT . I write the complete steps below, hoping to help others./dist/my env:
@rodrigogs I actually dont get an error but no
.outputor.distcontent is generated. It seems like it might be generating under.nuxt/distbut that folder has both client and server folders and the client folder contains no index.htmlThis is on the latest version of @nuxt/bridge
3.0.0-27338323.1e98259but it doesn’t work with nuxt3
not work for me