vite-plugin-node icon indicating copy to clipboard operation
vite-plugin-node copied to clipboard

Error when evaluating SSR module (mongoose dependency)

Open a-ski opened this issue 2 years ago • 1 comments

Reproduction steps

  1. git clone https://github.com/a-ski/vite-node.git
  2. yarn install
  3. yarn dev
  4. 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

  1. How to disable SSR if I don't use it at all?
  2. Why does it try resolve nested dependencies, which btw are optional in the mongodb package?
  3. How can I prevent it from happening?

a-ski avatar Mar 20 '22 18:03 a-ski

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.

axe-me avatar May 11 '22 09:05 axe-me

@a-ski did you manage to find a solution for this?

BipinBhandari avatar Dec 01 '22 19:12 BipinBhandari

it works fine with vite 4 and latest version of this plugin. please test it out.

axe-me avatar Jan 12 '23 03:01 axe-me