frandiox / vitedge

Edge-side rendering and fullstack Vite framework
https://vitedge.js.org
MIT License
729 stars 31 forks source link

Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/vitedge/plugin.js not supported. #54

Closed mihailtd closed 3 years ago

mihailtd commented 3 years ago

Hello, I am trying to run vitessedge-template, however when running npm run dev I get the following error:

/home/mihai/health-plus/@app/homepage/vite.config.ts:37
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
                               ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/user/projeect/@app/homepage/node_modules/vitedge/plugin.js from /home/user/project/@app/homepage/vite.config.ts not supported.
Instead change the require of plugin.js in /home/user/projeect/@app/homepage/vite.config.ts to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/user/projeect/@app/homepage/vite.config.ts:37:32)
    at Object.require.extensions.<computed> [as .ts] (/home/user/projeect/node_modules/vite/dist/node/chunks/dep-98dbe93b.js:76005:20)
    at loadConfigFromBundledFile (/home/user/projeect/node_modules/vite/dist/node/chunks/dep-98dbe93b.js:76013:17)
    at loadConfigFromFile (/home/user/projeect/node_modules/vite/dist/node/chunks/dep-98dbe93b.js:75932:32)
    at async resolveConfig (/home/user/projeect/node_modules/vite/dist/node/chunks/dep-98dbe93b.js:75504:28)
    at async getProjectInfo (file:///home/user/projeect/@app/homepage/node_modules/vitedge/config.js:5:18)
    at async file:///home/user/projeect/@app/homepage/node_modules/vitedge/bin/cli.js:38:22 {
  code: 'ERR_REQUIRE_ESM'
}

import statement is import vitedge from "vitedge/plugin.js";

env: node v16.7.0 but also tried 14.17.0 vite v2.4.4 typescript 4.4.1-rc vitedge: 0.15.1 but also tried 0.15.0 and 0.14.0

Any ideeas? Thanks!

frandiox commented 3 years ago

Hi! Did you change anything in the template? It works for me with both Node 14 and 16 🤔 Are you on Windows by any chance?

Can you also try npm run preview:watch and see if at least that works?

mihailtd commented 3 years ago

Hi, Thanks for the answer! The problem seems to be because of my monorepo setup with yarn - some dependency mismatch.

I will keep investigating however, this issue can be closed since I was able to run the template independently outside of my monorepo with no problem.

Thanks again!