bendrucker / azure-blob-to-s3

Batch copy files from Azure Blob Storage to Amazon S3
MIT License
47 stars 19 forks source link

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ...node_modules/meow/index.js #44

Closed armaseg closed 3 years ago

armaseg commented 3 years ago

When you try to run the CLI command cli.js --azure-connection $AZURE_CONNECTION_STRING --azure-container $AZURE_CONTAINER --aws-bucket $AWS_BUCKET --aws-prefix $AWS_PREF --concurrency 100 you get the following message:

internal/modules/cjs/loader.js:1015
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /codebuild/output/src293286341/src/node_modules/meow/index.js
require() of ES modules is not supported.
require() of /codebuild/output/src293286341/src/node_modules/meow/index.js from /codebuild/output/src293286341/src/node_modules/azure-blob-to-s3/cli.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 /codebuild/output/src293286341/src/node_modules/meow/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/codebuild/output/src293286341/src/node_modules/azure-blob-to-s3/cli.js:5:14)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
  code: 'ERR_REQUIRE_ESM'
}

I tested it with node version 15.14.0 and node version 12

armaseg commented 3 years ago

Downgrading to "meow": "9.0.0", solves this issue

bendrucker commented 3 years ago

Oops yes. Will take care of this and then cut a new breaking release with ESM.