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.

Can't use `require` in blank node project

See original GitHub issue

Does it only work with import?

Screenshot from 2022-06-19 13-37-53

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bennyschmidtcommented, Jun 21, 2022

Node environment supports imports since node v12.

Incorrect

Why do you need require?

The same reason millions of other projects do, JavaScript isn’t just React and Webpack.

Don’t worry about it. The 4 other libraries you put together to make this one already have Node support so I can just use them directly

1reaction
coderaisercommented, Jun 20, 2022

Yes, only import supported.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node: Require Not Working for One Module - Stack Overflow
I am working on a Node project with MongoDB/Mongoose. ... I use the Institution model in several other files and they all work...
Read more >
Requiring modules in Node.js: Everything you need to know
The first argument is the exports object, which starts empty. Then we have the require / module objects, both of which are instances...
Read more >
Use Import Instead of Require in Node App - In Plain English
How to Use Import Instead of Require Statements in a Node App. ... This will create an empty Node project. Now run this...
Read more >
Error while building with webpack · Issue #417 - GitHub
I tried building with webpack. index.js const FileType = require('file-type/browser'); webpack.config.js const path = require('path'); ...
Read more >
Top 10 Most Common Node.js Developer Mistakes - Toptal
Often, reasons for such criticisms are rooted in how developers use/misuse the language. This article explores ten common mistakes that Node.js developers make ......
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