Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jonaspauleta's avatar

Inertia SSR error in public/js/ssr.js

Hi guys, I'm setting up my base project with Jetstream, Ziggy, and the follwoing Inertia features: SSR on server side, and code splitting and dynamic imports on client side but I get this message when running the public/js/ssr.js in node, but I can't figure it out on why it logs this error, I can't even understand this error.

Print screen: https://i.ibb.co/y6v3F4G/Screenshot-2022-03-14-at-06-42-39.png

0 likes
11 replies
Sinnbeck's avatar

Check your code for usages of document.. Start with Welcome.vue

1 like
jonaspauleta's avatar

@Sinnbeck Well, I think it is a good point, but even without that code it still logs the error. Just commited to github

Sinnbeck's avatar

What command did you run exactly to get the error? Are you sure that you compiled the ssr.js without error? I just gave it a shot and got an error, that it could not find ziggy. After fixing that, it compiled, and I could run node public/js/ssr.js

To fix it I ran npm i ziggy-js and changed this line https://github.com/jonaspauleta/portfolio/blob/main/resources/js/ssr.js#L6

import route from 'ziggy-js'

I then ran npm run dev-ssr, and it worked after that

1 like
Sinnbeck's avatar

If the above does not work, it might we worth checking if you have a newer version of node. I tested with version 16.14

1 like
jonaspauleta's avatar

@Sinnbeck to reproduce the error: compile everything, serve the app, and while running "node public/js/ssr.js" open homepage (http://localhost:8000/), you will se the error on the command prompt you are running "node public/js/ssr.js". Anyway, I run "npm i ziggy-js" and set everything up as you sayed, but still, getting the error. The app runs perfectly, that's a fact, but this error/log is puzzling me...

Error: https://i.ibb.co/ZzCY57d/Screenshot-2022-03-14-at-09-06-58.png

jonaspauleta's avatar
jonaspauleta
OP
Best Answer
Level 3

@Sinnbeck just solved the issue now, and pushed a commit into github, easy solution, just had to had extractStyles to mix config

Thanks for your help :D

Sinnbeck's avatar

@jonaspauleta Ah great to hear, and its good that you posted the final solution. :) Sorry that I didnt have a solution

1 like

Please or to participate in this conversation.