2.5.21
https://github.com/AlexandreBonaventure/repro-vue-ssr-bug
yarn installyarn run ssr:build && yarn ssr:startto serve / correctly
error 500:
TypeError: Cannot read property 'replace' of undefined
at normalizeFile (.../node_modules/vue-server-renderer/build.js:8183:27)
Hi, I came across this weird bug when I was trying to retrieve a global variable (eg. global.localenv.PUBLIC_URL) in App.vue to populate a meta tag (using vue-meta).
I stumble upon the bug, and narrowed it down to referencing process being the cause here.
Another weird thing is that if you remove the component Icons import in the minimal repro, it works fine!
The error stack is initiated by TemplateRenderer.renderPreloadLinks which makes me think that maybe it is a bug in the webpack SSRClientPlugin which inject preload links for every assets.
+1
I'm experiencing the same issue TypeError: Cannot read property 'replace' of undefined.
Downgrading to [email protected], [email protected] and [email protected] made my application run again.
2.5.18-2.5.21 make my application break with the TypeError:
TypeError: Cannot read property 'replace' of undefined
at normalizeFile (.../node_modules/vue-server-renderer/build.js:8176:27)
Same error here since five days, this morning magically disappeared :thinking:
same error here
fix it, maybe will should put VueSSRClientPlugin in a right place
I had this error too when building my client webpack config. It turns out that I forgot to delete VueSSRServerPlugin() and had both the server and client plugin. As soon as I removed the server plugin from the client config it works.
I am not sure if it's related but someone else might have the same issue.
For me, the error was caused by a malformed vue-ssr-client-manifest.json : in the modules section, some modules were mapped to indexes -1. As a result, at runtime, the vue-server-renderer was unable to load the file.
To fix it, I just enabled the source maps for css files. In vue.config.js, add to your client config :
css: {
sourceMap: true,
},
Tested with version 2.6.9.
I hope this will help.
@laure-at-irun yep! that was my issue as well
@laure-at-irun This fixed the issue for me too. But why!?
The vue client plugin receives from webpack compilation stats a list of files that includes css maps, even when css maps are not emitted. The list is provided by webpack though stats.chunks.files. The stats.assets doesn't contain the css map files.
However, I am not sure why webpack is doing this.
Anyway, the client plugin is not robust to webpack inconsistent data.
The vue client plugin receives from webpack compilation stats a list of files that includes css maps, even when css maps are not emitted. The list is provided by webpack though stats.chunks.files. The stats.assets doesn't contain the css map files.
However, I am not sure why webpack is doing this.
Anyway, the client plugin is not robust to webpack inconsistent data.
Maybe souceMap in chunks is set by option: devtool.
Most helpful comment
For me, the error was caused by a malformed
vue-ssr-client-manifest.json: in the modules section, some modules were mapped to indexes-1. As a result, at runtime, thevue-server-rendererwas unable to load the file.To fix it, I just enabled the source maps for css files. In
vue.config.js, add to your client config :Tested with version 2.6.9.
I hope this will help.