Error AtlasError Documentation and Resolution

Node.js JSON import is missing its type attribute

TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///app/data.json" needs an import attribute of "type: json"

An ES module imports JSON without telling Node which module type to load. Current Node releases require an explicit JSON import attribute; a bundler may accept source that direct Node execution rejects.

ERR_IMPORT_ATTRIBUTE_MISSINGmodules
TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///app/data.json" needs an import attribute of "type: json"
  • A JSON file is imported with an ordinary JavaScript import statement.
  • A transform removes import attributes or emits older assertion syntax for a newer Node runtime.
  1. Check node --version in the failing environment and inspect the emitted JavaScript, not only the TypeScript source.
  2. On current supported Node versions, use import data from './data.json' with { type: 'json' }. For dynamic loading, use await import('./data.json', { with: { type: 'json' } }) and read the default export.
  3. Configure the compiler or bundler to preserve syntax supported by the deployment runtime. Older import assertions and newer import attributes are version-dependent, so match the runtime rather than changing syntax blindly.
  4. Run the built entry point with the same Node version used in production. A successful bundler build alone does not validate direct Node module loading.
Node.js Docs: Import attributes