wobsoriano / nuxt-proxy

Http-proxy middleware for Nuxt 3.
MIT License
92 stars 9 forks source link

Not starting after build #17

Closed KhaledAlMana closed 1 year ago

KhaledAlMana commented 1 year ago

Environment

Reproduction

Build and start or preview

Error

/path/to/my/project/.output/server/node_modules/http-proxy-middleware/dist/path-rewriter.js:4
const isPlainObj = require("is-plain-obj");
                   ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/my/project/.output/server/node_modules/is-plain-obj/index.js from /path/to/my/project/.output/server/node_modules/http-proxy-middleware/dist/path-rewriter.js not supported.
Instead change the require of index.js in/path/to/my/project/.output/server/node_modules/http-proxy-middleware/dist/path-rewriter.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/path/to/my/project/.output/server/node_modules/http-proxy-middleware/dist/path-rewriter.js:4:20)
    at Object.<anonymous> (/path/to/my/project/.output/server/node_modules/http-proxy-middleware/dist/http-proxy-middleware.js:8:22)
    at Object.<anonymous> (/path/to/my/project/.output/server/node_modules/http-proxy-middleware/dist/index.js:18:33)
    at async Promise.all (index 0) {
  code: 'ERR_REQUIRE_ESM'
}
 ELIFECYCLE  Command failed with exit code 1.
wobsoriano commented 1 year ago

Can you try v0.3.12?

palexander commented 1 year ago

I can confirm the same error with v0.3.12, but I cannot reproduce it with a toy example. Same node, nuxt, nitro versions as reported above. Also using vite. Adding these additional library and config options to the toy project does not trigger the issue.

The error only happens when running nuxt start or node .output/server/index.mjs, using nuxt dev runs just fine.

Any pointers on where I should look? I'm happy to continue to investigate, but it would be nice to narrow my focus.

wobsoriano commented 1 year ago

Try the latest version please, thanks!

Feel free to reopen it if you still get the error.