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

Error [ERR_REQUIRE_ESM]: require() of ES Module from vercel dependency #11102

Open
kevinreber opened this issue Jan 29, 2024 · 5 comments
Open

Comments

@kevinreber
Copy link

kevinreber commented Jan 29, 2024

Summary

Integrated Sentry into my Remix app that is deployed via Vercel and getting this error message during build (see PR)

Running "yarn run build"
--
17:57:28.365 | yarn run v1.22.17
17:57:28.398 | $ remix build --sourcemap && sentry-upload-sourcemaps --org kevin-reber --project javascript-remix
17:57:29.165 | info  building... (NODE_ENV=production)
17:57:29.165 | warn  🚨  source maps enabled in production
17:57:29.165 | ┃ You are using `--sourcemap` to enable source maps in production,
17:57:29.165 | ┃ making your server-side code publicly visible in the browser.
17:57:29.165 | ┃ This is highly discouraged!
17:57:29.165 | ┃ If you insist, ensure that you are using environment variables for secrets
17:57:29.166 | ┃ and are not hard-coding them in your source.
17:57:29.166 | ┗
17:57:36.365 | info  built (7.1s)
17:57:36.456 | /vercel/path0/node_modules/cliui/build/index.cjs:291
17:57:36.456 | const stringWidth = require('string-width');
17:57:36.456 | ^
17:57:36.456 |  
17:57:36.456 | Error [ERR_REQUIRE_ESM]: require() of ES Module /vercel/path0/node_modules/string-width/index.js from /vercel/path0/node_modules/cliui/build/index.cjs not supported.
17:57:36.456 | Instead change the require of index.js in /vercel/path0/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
17:57:36.456 | at Object.<anonymous> (/vercel/path0/node_modules/cliui/build/index.cjs:291:21)
17:57:36.457 | at Object.<anonymous> (/vercel/path0/node_modules/yargs/build/index.cjs:1:60678)
17:57:36.457 | at Object.<anonymous> (/vercel/path0/node_modules/yargs/index.cjs:5:30)
17:57:36.457 | at Object.<anonymous> (/vercel/path0/node_modules/@sentry/remix/scripts/sentry-upload-sourcemaps.js:2:15) {
17:57:36.457 | code: 'ERR_REQUIRE_ESM'
17:57:36.457 | }
17:57:36.457 |  
17:57:36.457 | Node.js v20.9.0
17:57:36.470 | error Command failed with exit code 1.
17:57:36.471 | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
17:57:36.493 | Error: Command "yarn run build" exited with 1

Screenshots below
CleanShot 2024-01-28 at 18 10 33@2x
CleanShot 2024-01-28 at 18 19 06@2x

Seems strange that this issue is coming from /vercel/path0/node_modules/cliui/build/index.cjs, but did not run into this before attempting to integrate Sentry.

Also confirming my package.json is set to "type": "module"

Steps to Reproduce

Issue with occurs during build (yarn run build) but did not run into this issue before attempting to integrate Sentry

References

@kevin-dev71
Copy link

i have the same error but when i try to run 'yarn test' with jest

@yuzushioh
Copy link

I have the same error

@justyn-clark
Copy link

Screenshot 2024-03-21 at 11 50 34 AM Screenshot 2024-03-21 at 11 55 22 AM

I was happy about finally getting to deploy Remix with Vite on Vercel and was doing so rapidly for the past 2 weeks and all of a sudden in the past 2 days, without me touching anything I'm getting the same.

Literally did nothing and now I can't deploy and my production app is down. This is not cool.

@juliomuhlbauer
Copy link

juliomuhlbauer commented Apr 4, 2024

same error

image

@TooTallNate
Copy link
Member

@kevinreber I checked out your repo + sentry branch, and I see the same failure locally, so I don't think this is specific to Vercel. The error happens within the sentry-upload-sourcemaps command, when cliui attempts to require('string-width') which is seemingly an ESM module.

I found this related issue (yargs/cliui#138). Looks like this was a yarn bug. It works correctly when I install the deps with npm instead of yarn. I suggest you do the same.

For anyone else in this thread, if switching off of yarn doesn't help, please share a reproduction if you would like me to take a closer look.

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

6 participants