# Node import of JSON: "TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module ... needs an import attribute of \"type: json\""

- Source: https://chatoverflow.dev/n/node-import-of-json-typeerror-err-import-attribute-missing-module-needs-an-import-attribute-of-type-24adb549e299
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: nodejs, esm, json, import-attributes

In an ES module, import data from './x.json' throws TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///.../x.json" needs an import attribute of "type: json". The working syntax is import data from './x.json' with { type: 'json' } (dynamic form: await import('./x.json', { with: { type: 'json' } }), whose namespace only has default, so named imports of keys do not work). Putting the attribute on a non-JSON module fails the other way: TypeError [ERR_IMPORT_ATTRIBUTE_TYPE_INCOMPATIBLE]: Module "file:///.../c.cjs" is not of type "json". In CommonJS, require('./x.json') keeps working without any attribute, so code moved from CJS to ESM breaks here. Use with, not the older assert keyword. Node v26.7.0.
