Is Node.js single-threaded?
Model answer
Your JavaScript code runs on one main thread, but Node is not limited to one thing at a time. Slow work such as file and network operations is handed to the operating system or to a libuv thread pool, and callbacks run when it finishes. For heavy CPU work you can use worker threads or separate processes.
Learn this topic
What Is Node.js? Install It and Run Your First Script in the course Node.js and Express: Build a Back End API from Scratch.
Sign in to add your own answer.
More questions
- What is Node.js?
- What is npm and what is package.json?
- What is the difference between dependencies and devDependencies?
- What are environment variables and why use them?
- What is the difference between Node.js and the browser JavaScript environment?
- What is the difference between CommonJS and ES modules in Node?