About 29,200 results
Open links in new tab
  1. ES6 import equivalent of require() without exports

    Sep 3, 2017 · By using require(./filename) I can include and execute the code inside filename without any export defined inside filename itself. What is the equivalent in ES6 using import? …

  2. node.js - Using require without export - Stack Overflow

    To get it to work, I need to export the foo object from my module, using the module.exports that you are familiar with. This demonstrates that you don't need to export anything from your …

  3. Using Node.js require vs. ES6 import/export - Stack Overflow

    Jul 11, 2015 · node --experimental-modules index.mjs lets you use import without Babel and works in Node 8.5.0+. You can (and should) also publish your npm packages as native …

  4. Import and Export in Node.js - GeeksforGeeks

    Jan 7, 2025 · Node.js also allows importing and exporting functions and modules. Functions in one module can be imported and called in other modules saving the effort to copy function …

  5. Usingimport” instead of “require” in Node.js - Medium

    Apr 25, 2024 · In this article, let’s see how to transition from “require” to “import” in a Node.js project. ECMAScript Modules (ESM) is a standardized module system in JavaScript that …

  6. How To Use An ES6 Import In Node.js? - GeeksforGeeks

    Jan 7, 2025 · To use an ES6 import in Node.js, you need to make some configurations to support ES6 modules. While Node.js was originally built around the CommonJS module system …

  7. Use Import Instead of Require in Node App - Plain English

    Jul 12, 2021 · Thanks to the support of ESM files in Node.js, the days of using const something = require('something') are a thing of the past. Let’s learn how easy it can be to switch to using …

  8. How to use `import/export` in Node without Babel - Corey Cleary

    There is experimental support for ECMAScript modules in newer version of Node using the --experimental-modules flag. But I've found a more robust and interoperable solution to use is …

  9. Using import/export in node.js with esm | by Jamis Charles

    Jul 8, 2018 · Thankfully John-David Dalton (who created Lodash) made the esm module, which allows us to use es6 import/export syntax in node without a build step. Esm is a simple npm …

  10. Difference Between Node Require and ES6 Import And Export

    Feb 18, 2025 · NodeJS offers two ways to do this: CommonJS (require ()) and ES6 modules (import/export). Both achieve the same goal—sharing code, but use different syntax. …

Refresh