SimplyStaking / polkadot_api_server

API Server in JavaScript for Querying Polkadot Nodes
Apache License 2.0
32 stars 15 forks source link

ERR_REQUIRE_ESM when running Docker #30

Closed tomjohnburton closed 3 years ago

tomjohnburton commented 3 years ago
Digest: sha256:6ca0c4be48b3d4c29ff8df8cd4c70ac4c4c15237e27f04271077843d74615932
Status: Downloaded newer image for simplyvc/polkadot_api_server:1.28.1
internal/modules/cjs/loader.js:1173
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /opt/polkadot_api_server/node_modules/@polkadot/api/index.js
require() of ES modules is not supported.
require() of /opt/polkadot_api_server/node_modules/@polkadot/api/index.js from /opt/polkadot_api_server/src/server.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 index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /opt/polkadot_api_server/node_modules/@polkadot/api/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173:13)
    at Module.load (internal/modules/cjs/loader.js:1001:32)
    at Function.Module._load (internal/modules/cjs/loader.js:900:14)
    at Module.require (internal/modules/cjs/loader.js:1043:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/opt/polkadot_api_server/src/server.js:3:34)
    at Module._compile (internal/modules/cjs/loader.js:1157:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
    at Module.load (internal/modules/cjs/loader.js:1001:32)
    at Function.Module._load (internal/modules/cjs/loader.js:900:14) {
  code: 'ERR_REQUIRE_ESM'
dillu24 commented 3 years ago

Hi @tomjohnburton , can you please confirm whether the latest release works for you?