node_modules in server side? #571
Replies: 2 comments 11 replies
-
What's the full stack trace? |
Beta Was this translation helpful? Give feedback.
-
@brillout, I also ran into this same error when I tried to use this the examples/redux template with a specific 3rd-party package. (In my case the 3rd-party package is react-live-runner, which seems to have all the modern JS exports set-up, but still throws this error.) I wrote a question on StackOverflow before I found this discussion, and that has a bunch of details. In my case, the full error is:
I split the examples/redux code into a repo and added the package that's causing problems here: https://github.com/antun/vite-ssr-redux-react-live-runner-example |
Beta Was this translation helpful? Give feedback.
-
I am using https://github.com/brillout/vite-plugin-ssr/tree/main/examples/react-router/
And I get a lot of
Cannot use import statement outside a module
when importingnode_modules/*/*.js
files to server. I guess it's because node.js runtime run the raw file ofimport xxx
instead of the transpiledrequire(xxx)
After hacking
type="module"
in the package.json of those node_modules it works. But it's annoying, since the deps are deeply nested and I constantly get these errors.My question
type="module"
?import xxx
and what should I do? Should I add some transpilation to server files?Beta Was this translation helpful? Give feedback.
All reactions