About 748,000 results
Open links in new tab
  1. javascript - How should I import JSON in Node? - Stack Overflow

    Mar 20, 2021 · You're using Node.js in ESM mode, ESM does not currently import JSON modules by default. You can either: Turn on JSON module importing (by passing a CLI flag) OR; Create …

  2. Import a JSON file in JavaScript and Node.js (ES6 Modules)

    Mar 6, 2024 · To import a JSON file in Node.js: Make sure you are running Node.js version 17.5 or more recent. Make sure the type property in your package.json file is set to module. Use an …

  3. How to import JSON files in ES modules (Node.js)

    May 16, 2021 · Learn about the ways to read and import JSON files in Node.js ECMAscript modules (ESM).

  4. is there a require for json in node.js - Stack Overflow

    With node v23 you can import json files by using this: import data from './folder/file.json' with { type: 'json' } export default { foo { console.log(data) } } You no longer need the experimental …

  5. Import JSON file in NodeJs using es6 - Stack Overflow

    Dec 19, 2019 · If you want to use ES6 (NOT CommonJS) module system but want to use the Node.js version which is less than V18 (supports direct json import) then use the below approach.

  6. How to read and write JSON file using Node - GeeksforGeeks

    Jan 7, 2025 · A straightforward way to read a JSON file in a Node JS file is by using the ` require() ` method to include it. Syntax: const data = require('path/to/file/filename'); Example: Create a …

  7. How to Import a JSON File in JavaScript/Node.js - Stack Abuse

    Sep 18, 2023 · Importing a JSON file in Node.js is very easy to do since JSON is a native type to JS. You can use the built-in fs (file system) module to read the file, and then parse it into a …

  8. Reading and writing JSON files in Node.js: A complete tutorial

    Oct 18, 2024 · Node.js provides built-in modules and third-party libraries for reading and writing JSON files. It offers flexible methods to suit various needs, such as handling small JSON …

  9. Importing JSON and Watch Mode in Node.js - DEV Community

    Mar 1, 2025 · Node.js makes it super easy to import JSON files directly! 🚀. Before ES Modules, the most common way to import JSON was using require: This works only in CommonJS (require …

  10. 5 Ways to Read JSON Files in Node.js - Kindacode

    Importing JSON Modules. At the time of writing, importing JSON modules is an experimental feature and might change at any time. The syntax is neat and clean: import data from …

  11. Some results have been removed