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.
TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///app/data.json" needs an import attribute of "type: json"
Why it happens
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.
How to fix it
Check node --version in the failing environment and inspect the emitted JavaScript, not only the TypeScript source.
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.
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.
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.