-
Notifications
You must be signed in to change notification settings - Fork 125
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 #725
Comments
I am getting this same error too. Could you let me know if you were able to resolve this? |
@neerajnerlekar are you still seeing this on the latest version? It should have been fixed. If not can you send me an updated stacktrace? The one in the report here seems to be related to something we fixed, so there might be something else that's not CJS compatible |
I am getting this same error too. |
@HarukiKondo can you post a stack trace of your error? |
@moldy530 Ok. Here is a stack trace in my case node_modules/ts-node/dist/index.js:851
return old(m, filename);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/@wagmi/core/dist/esm/exports/index.js from node_modules/@alchemy/aa-alchemy/dist/cjs/config/utils/cookies.js not supported.
Instead change the require of index.js in node_modules/@alchemy/aa-alchemy/dist/cjs/config/utils/cookies.js to a dynamic import() which is available in all CommonJS modules.
at require.extensions.<computed> [as .js] (node_modules/ts-node/dist/index.js:851:20)
at Object.<anonymous> (node_modules/@alchemy/aa-alchemy/dist/cjs/config/utils/cookies.js:7:16)
at require.extensions.<computed> [as .js] (node_modules/ts-node/dist/index.js:851:20) {
code: 'ERR_REQUIRE_ESM'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /home/ubuntu/.nvm/versions/node/v20.13.1/bin/node
Arguments: /home/ubuntu/.nvm/versions/node/v20.13.1/lib/node_modules/yarn/lib/cli.js aa:test
Directory: /home/ubuntu/environment/NFTSmartKeyPoc/packages/cdk-nft-sample
Output:
info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. |
I executed on AWS Cloud9. "dependencies": {
"@alchemy/aa-accounts": "^3.18.2",
"@alchemy/aa-alchemy": "3.16.0",
"@alchemy/aa-core": "3.16.0",
} |
Ah yeah, try upgrading all the packages to 3.18.2 and see if that resolves it |
@moldy530 Thank you! I will try it! |
@moldy530 I upgraded all the packages to 3.18.2. But I am getting this same error too. |
I updated it to 3.18.2 and I am still getting the same error in stack trace. I even cloned Dan's github repo associated with the video, and it still gives the same error Here is my {
"name": "aa-sdk-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^20.12.3",
"ts-node": "^10.9.2",
"typescript": "^5.4.3"
},
"dependencies": {
"@alchemy/aa-alchemy": "^3.18.2",
"@alchemy/aa-core": "^3.18.2",
"dotenv": "^16.4.5",
"viem": "^2.9.15"
}
} Here is the stack trace of the error. node_modules/ts-node/dist/index.js:851
return old(m, filename);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/aa-sdk-userops/node_modules/@wagmi/core/dist/esm/exports/index.js from /home/aa-sdk-userops/node_modules/@alchemy/aa-alchemy/dist/cjs/config/utils/cookies.js not supported.
Instead change the require of index.js in /home/aa-sdk-userops/node_modules/@alchemy/aa-alchemy/dist/cjs/config/utils/cookies.js to a dynamic import() which is available in all CommonJS modules.
at require.extensions.<computed> [as .js] (/home/aa-sdk-userops/node_modules/ts-node/dist/index.js:851:20)
at Object.<anonymous> (/home/aa-sdk-userops/node_modules/@alchemy/aa-alchemy/dist/cjs/config/utils/cookies.js:7:16)
at require.extensions.<computed> [as .js] (/home/aa-sdk-userops/node_modules/ts-node/dist/index.js:851:20) {
code: 'ERR_REQUIRE_ESM'
} |
ah the issue is the version of wagmi :/ https://wagmi.sh/react/guides/migrate-from-v1-to-v2#dropped-commonjs-support wagmi in v2 no longer supports CJS. Most likely you'll have to migrate over to using ESM instead of CJS. We'll take a look at the example repo as well and double check that it's setup for ESM |
[REQUIRED] Environment
[REQUIRED] Describe the problem
Before and including version 3.9.0 didn't have this issue. Trying to upgrade for several weeks already, resulting in following issue:
How to reproduce:
Relevant code or sample repro:
The text was updated successfully, but these errors were encountered: