vite-plugin-node
vite-plugin-node copied to clipboard
Error when evaluating SSR module (mongoose dependency)
Reproduction steps
- git clone https://github.com/a-ski/vite-node.git
- yarn install
- yarn dev
- curl localhost:3000
Error
18:44:51 [vite] Error when evaluating SSR module ./src/index.ts: Error: Cannot find module 'mongodb-extjson' imported from 'MY_FS_PATH\vite-node\node_modules\mongodb\lib\core\utils.js' at viteResolve (MY_FS_PATH\vite-node\node_modules\vite\dist\node\chunks\dep-9c153816.js:56216:25) at Function.
(MY_FS_PATH\vite-node\node_modules\vite\dist\node\chunks\dep-9c153816.js:56233:28) at Function.Module._load (internal/modules/cjs/loader.js:747:27) at Module.require (internal/modules/cjs/loader.js:974:19) at Object.require (internal/modules/cjs/helpers.js:88:18) at _optionalRequire (MY_FS_PATH\vite-node\node_modules\mongodb\node_modules\optional-require\dist\index.js:83:65) at x (MY_FS_PATH\vite-node\node_modules\mongodb\node_modules\optional-require\dist\index.js:144:16) at Object.retrieveEJSON (MY_FS_PATH\vite-node\node_modules\mongodb\lib\core\utils.js:50:15) at Object. (MY_FS_PATH\vite-node\node_modules\mongodb\lib\core\index.js:5:34) at Module._compile (internal/modules/cjs/loader.js:1085:30)
Questions
- How to disable SSR if I don't use it at all?
- Why does it try resolve nested dependencies, which btw are optional in the mongodb package?
- How can I prevent it from happening?
sry, after searching around on this issue, I don't see a good solution for this. I might need to dig deep into vite to see if I can find a workaround.
@a-ski did you manage to find a solution for this?
it works fine with vite 4 and latest version of this plugin. please test it out.