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

Issue with ESM mode #3149

Open
HaykSahakyan opened this issue Dec 30, 2022 · 0 comments
Open

Issue with ESM mode #3149

HaykSahakyan opened this issue Dec 30, 2022 · 0 comments
Labels

Comments

@HaykSahakyan
Copy link

Environment Details

  • OS: AWS AMI Linux
  • Node Version: v14.17.4 / v14.19.3 / v16.15.0
  • Yarn Version: NPM 6.14.14 / 6.14.17 / 8.5.5
  • BitGoJS Version: 13.0.1 / 13.1.0 / 16.2.1
  • BitGo Environment: testnet

Expected Behavior

Current Behavior

Trying to run the application with ESM in all the abovementioned environments.

pm2 start index.js --node-args="-r esm" --name="bank" -f

Getting the following error:

/home/ec2-user/.nvm/versions/node/v14.17.4/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:1
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /srv/web/cc-bank/node_modules/@polkadot/keyring/pair/decode.js
require() of ES modules is not supported.
require() of /srv/web/cc-bank/node_modules/@polkadot/keyring/pair/decode.js from /srv/web/cc-bank/node_modules/@bitgo/sdk-coin-dot/dist/src/lib/utils.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename decode.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /srv/web/cc-bank/node_modules/@polkadot/keyring/package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1089:13)
at Object.Hook._require.Module.require (/home/ec2-user/.nvm/versions/node/v14.17.4/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:101:39) {
code: 'ERR_REQUIRE_ESM'
}

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

No branches or pull requests

1 participant