Skip to content

TypeError[ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension “.json” – How to fix ?

Since ES6 when you try to import JSON file you might face this error.

node distance-calculator.js
node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".json" for /home/Anand/Documents/poopatom8/zips.json

To fix this error simple add the flag –experimental-json-modules to your node.js run command.

node --experimental-json-modules distance-calculator.js
See also  Anti-shake throttling in JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.