Skip to content

Resolution of this package as ESM is broken due to missing package.json in esm output #269

@ajaffie

Description

@ajaffie

NodeJS is resolving this package as CommonJS because a package.json file with "type": "module" is missing from the esm output.
Here is the error I am getting:

SyntaxError: Named export 'LabelFilter' not found. The requested module '@azure/app-configuration-provider' is a CommonJS module, which may not support all module.exports as named exports.
  CommonJS modules can always be imported via the default export, for example using:

  import pkg from '@azure/app-configuration-provider';
  const { LabelFilter, load } = pkg;

      at ModuleJob._instantiate (node:internal/modules/esm/module_job:220:21)
      at async ModuleJob.run (node:internal/modules/esm/module_job:321:5)
      at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
      at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

  Node.js v22.17.1

If I add a package.json to the dist/esm folder with the contents below, then the error is fixed:

{
  "type": "module"
}

I copied this from the @azure/app-configuration package's esm folder.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions