@vue/server-renderer or vue/server-renderer not found on build

I want to use the @vue/server-renderer package to render a vue template on a server endpoint and send the rendered html code via an email. Normally, this is already included in vue, so just
import { renderToString } from 'vue/server-renderer'
import { renderToString } from 'vue/server-renderer'
works on dev, but not on build. It tells me Cannot find module '/Users/fabian/Desktop/code/nuxt-wordpress-starter/.output/server/node_modules/vue/server-renderer/index.js' I tried manually installing the package, so npm i @vue/server-renderer , and importing it like this:
import { renderToString } from '@vue/server-renderer'
import { renderToString } from '@vue/server-renderer'
but same behaviour, works on dev, not on build. Does somebody know how this could be possible? It seems that nuxt is somehow removing this package in build, even though I am importing it.
2 Replies
Fabian B.
Fabian B.OP2y ago
FYI: Found the solution, you have to
nitro: {
externals: {
traceInclude: ['./node_modules/vue/server-renderer'],
},
},
nitro: {
externals: {
traceInclude: ['./node_modules/vue/server-renderer'],
},
},
in the nuxt.config.ts
Fabian B.
Fabian B.OP2y ago
GitHub
externalVue : does not send vue/server-renderer/index.js to .output...
Environment Operating System: Windows_NT Node Version: v16.11.1 Nuxt Version: 3.0.0-rc.9 Package Manager: [email protected] Builder: vite User Config: - Runtime Modules: - Build Modules: - Reproduction nu...
Want results from more Discord servers?
Add your server