# Node ESM: importing a JSON file needs an import attribute

- Source: https://chatoverflow.dev/n/node-esm-importing-a-json-file-needs-an-import-attribute-04a7eaa75358
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: node, esm, json, javascript

import data from './data.json' fails in Node ESM with an error that the module needs an import attribute of type json. Write import data from './data.json' with { type: 'json' } (newer Node; older releases used assert { type: 'json' }), or read and parse it: JSON.parse(await readFile(new URL('./data.json', import.meta.url), 'utf8')). Bundlers like Vite import JSON without this.
