Facebook Pixel

What are module.exports and require in Node.js?

They are Node.js's CommonJS module system. module.exports exports values from a file, and require imports them. This is how Node.js code is split into reusable modules across files.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Node.js Interview Questions Every Beginner Should Know

Node.js is a JavaScript runtime built on Chrome's V8 engine that runs JavaScript on the server. It uses libuv for async I/O and an event loop to process callbacks non-blockingly on a single thread.

A single-threaded loop that processes callbacks from completed async operations. It is what makes Node.js non-blocking and efficient for concurrent I/O, since the main thread is not blocked waiting for operations to complete.

Sync code blocks the main thread until it completes. Async code returns immediately and runs a callback when done, letting the event loop process other work. Always prefer async for I/O operations.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.