ERR_IMPORT_ATTRIBUTE_MISSING 🟩 Node.js

TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module needs an import attribute of "type: json"

An ES module imported a .json file without the required import attribute.

Seen on: Node.js

Meaning

Native ESM requires with { type: 'json' } (older Node: assert { type: 'json' }) when importing JSON.

Common causes

  • import data from './data.json' without attributes
  • Older code using assert syntax on newer Node

⚡ Quick fix

  1. Use import data from './data.json' with { type: 'json' }
  2. Or read with fs and JSON.parse
  3. Or createRequire for CommonJS-style require

Detailed fix by platform

Node.js

  1. import config from './config.json' with { type: 'json' };

How to diagnose

  1. Import — How is the JSON imported?
  2. Node — Version?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.