question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

require() of ES modules is not supported

See original GitHub issue

Since eslint updated to v8.0.0, I get the following error:

require() of ES modules is not supported.
require() of /home/vsts/work/1/s/node_modules/eslint-scope/lib/definition.js from /home/vsts/work/1/s/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/vsts/work/1/s/node_modules/eslint-scope/package.json```

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
mdjermanoviccommented, May 21, 2022

@jais-shivam

Parsing error: require() of ES Module G:\DAPP\Fund\fund_transfer\node_modules\eslint-scope\lib\index.js from G:\DAPP\Fund\fund_transfer\node_modules\babel-eslint\lib\require-from-eslint.js not supported.

You are using deprecated babel-eslint. Please try with @babel/eslint-parser.

4reactions
jais-shivamcommented, May 22, 2022

@jais-shivam

Parsing error: require() of ES Module G:\DAPP\Fund\fund_transfer\node_modules\eslint-scope\lib\index.js from G:\DAPP\Fund\fund_transfer\node_modules\babel-eslint\lib\require-from-eslint.js not supported.

You are using deprecated babel-eslint. Please try with @babel/eslint-parser.

@mdjermanovic I am still getting the same error though my application is running now, my compiler is still throwing that error. image

This is still coming from the babel-eslint package (see node_modules\babel-eslint\ in the screenshot). Did you set parser: "@babel/eslint-parser" in your ESLint config file?

https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser#setup

Thank you @mdjermanovic my problem is resolved thanks for your help🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The node-fetch latest version doesn't use the require() syntax to import the package. You need to go to your package.json and type
Read more >
require() of ES modules is not supported · Issue #43833 - GitHub
An unhandled exception occurred: Must use import to load ES Module: /Users/jeb/angular-builders/packages/custom-webpack/dist/browser/index.js ...
Read more >
Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The error [ERR_REQUIRE_ESM]: require() of ES Module not supported. Instead change the require of index.js to a dynamic import() which is available in...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
Using require to load an ES module is not supported because ES modules have asynchronous execution. Instead, use import() to load an ES...
Read more >
require() of es module is not supported - You.com - You.com
The esm module you're adding is for adding ESM compatibility, but it's unnecessary now that Node 12+ supports ESM natively; and it doesn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found