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 running ignition when type in package.json is module: require() of ES Module ... not supported #6095

Open
vtamara opened this issue Dec 28, 2024 · 0 comments
Assignees

Comments

@vtamara
Copy link

vtamara commented Dec 28, 2024

Version of Hardhat

2.22.17

What happened?

Using ubuntu 24.04.01 with node 20.17.0, if I start a project with hardhat following the standard steps, and in the initialization with npm init I choose type: module when I try to run:

$ npx  hardhat ignition deploy ./ignition/modules/Lock.js

it produces the following error:

An unexpected error occurred:

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/vtamara/comp/js/phardhat/ignition/modules/Lock.js from /home/vtamara/comp/js/phardhat/node_modules/@nomicfoundation/hardhat-ignition/dist/src/utils/load-module.js not supported.
Instead change the require of Lock.js in /home/vtamara/comp/js/phardhat/node_modules/@nomicfoundation/hardhat-ignition/dist/src/utils/load-module.js to a dynamic import() which is available in all CommonJS modules.
    at loadModule (/home/vtamara/comp/js/phardhat/node_modules/@nomicfoundation/hardhat-ignition/dist/src/utils/load-module.js:29:18)
    at SimpleTaskDefinition.action (/home/vtamara/comp/js/phardhat/node_modules/@nomicfoundation/hardhat-ignition/dist/src/index.js:172:24)
    at async Environment._runTaskDefinition (/home/vtamara/comp/js/phardhat/node_modules/hardhat/internal/core/runtime-environment.js:228:20)
    at async Environment.run (/home/vtamara/comp/js/phardhat/node_modules/hardhat/internal/core/runtime-environment.js:91:24)
    at async main (/home/vtamara/comp/js/phardhat/node_modules/hardhat/internal/cli/cli.js:224:13) {
  code: 'ERR_REQUIRE_ESM'
}

This problem doesn't ocurr if during initialization with npm init I use type: commonjs

Minimal reproduction steps

$ mkdir phardhat
$ cd phardhat
$ npm init
...
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: 
license: (ISC) 
type: module
$ npx hardhat init
...
✔ What do you want to do? · Create a JavaScript project
✔ Hardhat project root: · /home/vtamara/comp/js/ph2
✔ Do you want to add a .gitignore? (Y/n) · y
✔ Do you want to install this sample project's dependencies with npm (hardhat @nomicfoundation/hardhat-toolbox)? (Y/n) · y
...
$ npx hardhat test
...
  9 passing (297ms)
$ npx node 
...
Account #19: 0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199 (10000 ETH)
Private Key: 0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e

WARNING: These accounts, and their private keys, are publicly known.
Any funds sent to them on Mainnet or any other live network WILL BE LOST.

and in another terminal

$ npx  hardhat ignition deploy ./ignition/modules/Lock.js

Search terms

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants