Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Error [ERR_REQUIRE_ESM]: require() #6

Open
andresgutgon opened this issue Mar 25, 2022 · 0 comments
Open

Fix Error [ERR_REQUIRE_ESM]: require() #6

andresgutgon opened this issue Mar 25, 2022 · 0 comments

Comments

@andresgutgon
Copy link
Owner

What?

Fix this error

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/p-queue/dist/index.js from /Users/andres/code/opensource/remix-storage/examples/basic/build/index.js not supported.
Instead change the require of /Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/p-queue/dist/index.js in /Users/andres/code/opensource/remix-storage/examples/basic/build/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/andres/code/opensource/remix-storage/examples/basic/build/index.js:440:30)
    at /Users/andres/code/opensource/remix-storage/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@remix-run/serve/index.js:40:17
    at Layer.handle [as handle_request] (/Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:137:13)
    at next (/Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:131:14)
    at next (/Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:131:14)
    at next (/Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:131:14)
    at next (/Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:131:14)
    at next (/Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:131:14)
    at next (/Users/andres/code/opensource/remix-storage/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:131:14)

p-queue is a dependency used in @remix-storage/bodyparser. It serves for making sure all fields and files are not left there processing in Busboy instance when there is an error.
[This post explains better than I do](https://bytearcher.com/articles/terminate-busboy/

The problem with this packages is that is not transpiled and Remix server breaks.

At the moment is posible to fix at developer side adding this to your Remix config

// remix.config.js
module.exports = {
  // other options
  serverDependenciesToBundle: [/^p-queue.*/, /^p-timeout.*/]
}

But it's annoying that if you use this package you have to know about its internals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant