Practice these MCQs to strengthen your Node.js knowledge and prepare confidently for job interviews or certification exams.
Whether you’re aiming to become a backend specialist, a full-stack developer, or simply sharpen your skills in asynchronous programming, REST APIs, and server-side JavaScript — you’re in the right place.
70+ Node.js MCQs covering everything from core modules, file systems, Express.js, middleware, events, asynchronous operations, and advanced concepts — complete with answers to help you test and solidify your understanding, no guesswork involved.
Section 1: Node.js Basics – 10 MCQs
- What is Node.js?
A. JavaScript framework
B. Programming language
C. JavaScript runtime built on Chrome’s V8 engine
D. Web server
✅ Answer: C - Which of the following is true about Node.js?
A. It’s synchronous by default
B. It uses event-driven, non-blocking I/O
C. It is compiled directly to machine code
D. It only runs on Windows
✅ Answer: B - Which command is used to initialize a Node.js project?
A. npm init
B. node start
C. node init
D. npm install
✅ Answer: A - Which of the following is NOT a global object in Node.js?
A. __dirname
B. window
C. require
D. process
✅ Answer: B - What will this code output?
console.log(typeof null);
A. null
B. object
C. undefined
D. string
✅ Answer: B
- Which module is used to create a server in Node.js?
A. fs
B. http
C. server
D. path
✅ Answer: B - How can you import a built-in module in Node.js?
A. import fs from ‘fs’
B. include(‘fs’)
C. require(‘fs’)
D. use(‘fs’)
✅ Answer: C - What will the following code do?
console.log(__dirname);
A. Print the directory name of the file
B. Print the file content
C. Print the current timestamp
D. Throw an error
✅ Answer: A
Master Node.js Interviews with Confidence – Quiz Your Way to Success
- What is the use of process.exit()?
A. Restart the script
B. Exit the Node.js process
C. Pause the process
D. Run in a loop
✅ Answer: B - Which of the following is NOT a core module?
A. fs
B. express
C. http
D. path
✅ Answer: B
Section 2: Modules & NPM – 10 MCQs
- What is NPM?
A. Node Programming Method
B. Node Package Manager
C. Network Process Manager
D. Node Parser Module
✅ Answer: B - Which file lists project dependencies?
A. package.json
B. node_modules
C. npm.config
D. server.js
✅ Answer: A - How do you install a package globally?
A. npm install package-name
B. npm install -g package-name
C. npm get package-name
D. npm global package-name
✅ Answer: B - What does npm update do?
A. Uninstalls packages
B. Updates the npm tool
C. Updates all packages
D. Upgrades Node.js
✅ Answer: C - Which keyword exports a module in Node.js?
A. return
B. exports
C. module.exports
D. require
✅ Answer: C - Which statement is correct?
module.exports = { add: function(a, b) { return a + b; } }
A. Exporting a function
B. Exporting an object
C. Invalid syntax
D. A and B
✅ Answer: D
- What is the purpose of require() in Node.js?
A. Define a class
B. Load modules
C. Create an HTTP request
D. Encrypt passwords
✅ Answer: B - What does npm init -y do?
A. Launch server
B. Generate default package.json
C. Install yarn
D. Open index.js
✅ Answer: B - What folder stores installed packages locally?
A. lib_modules
B. modules
C. node_modules
D. npm_files
✅ Answer: C - How can you uninstall a Node package?
A. npm delete <package>
B. npm remove <package>
C. npm uninstall <package>
D. npm clean <package>
✅ Answer: C
Section 3: File System & Events – 10 MCQs
- Which method reads a file asynchronously?
A. fs.read()
B. fs.readFileSync()
C. fs.readFile()
D. fs.loadFile()
✅ Answer: C - Which event is emitted when a stream ends?
A. close
B. finish
C. end
D. stop
✅ Answer: C - What does this code do?
const fs = require(‘fs’);
fs.writeFileSync(‘test.txt’, ‘Hello World’);
A. Writes file asynchronously
B. Appends to file
C. Writes file synchronously
D. Reads file
✅ Answer: C
- Which core module handles events?
A. fs
B. eventManager
C. events
D. process
✅ Answer: C
Level Up Your Node.js Skills with Interactive MCQs
- How do you emit a custom event?
emitter.emit(‘start’);
A. True
B. False
✅ Answer: A
- Which method creates an event listener?
A. on()
B. emit()
C. listen()
D. event()
✅ Answer: A - What will happen if an error event has no listener?
A. Node ignores it
B. Node logs it
C. Node throws an exception
D. Node retries
✅ Answer: C - What is the default encoding for reading files?
A. ASCII
B. Binary
C. UTF-8
D. ISO
✅ Answer: C - Which method deletes a file?
A. fs.remove()
B. fs.deleteFile()
C. fs.unlink()
D. fs.delete()
✅ Answer: C - Which module is required for file path operations?
A. os
B. url
C. dir
D. path
✅ Answer: D
Section 4: Express.js – 10 MCQs
- What is Express.js?
A. Frontend framework
B. Database driver
C. Web application framework for Node.js
D. JavaScript compiler
✅ Answer: C - Which command installs Express?
A. npm get express
B. npm add express
C. npm install express
D. node install express
✅ Answer: C - Which code sets up a basic Express server?
const express = require(‘express’);
const app = express();
app.listen(3000);
A. True
B. False
✅ Answer: A
- What method handles GET requests in Express?
A. app.fetch()
B. app.get()
C. app.req()
D. app.retrieve()
✅ Answer: B - Which is the correct way to send a response?
res.send(‘Hello World’);
A. True
B. False
✅ Answer: A
- What does req.params access?
A. Query parameters
B. Route parameters
C. Form data
D. Headers
✅ Answer: B - How do you parse JSON bodies in Express?
A. app.use(express.json())
B. app.json()
C. express.parseJSON()
D. req.body.json()
✅ Answer: A - Which middleware handles form submissions?
A. express.urlencoded()
B. express.forms()
C. app.useForms()
D. express.body()
✅ Answer: A - Which status code represents a successful POST request?
A. 200
B. 201
C. 404
D. 500
✅ Answer: B - How to define a dynamic route in Express?
app.get(‘/user/:id’, …)
A. True
B. False
✅ Answer: A
Section 5: APIs & Middleware – 10 MCQs
- What is middleware in Express?
A. A database layer
B. A route handler
C. A function executed between request and response
D. A frontend component
✅ Answer: C - Which method registers middleware globally?
A. app.add()
B. app.route()
C. app.use()
D. middleware()
✅ Answer: C - What does the next() function do in middleware?
A. Stops execution
B. Sends response
C. Passes control to the next middleware
D. Returns JSON
✅ Answer: C - Which response method sends JSON data?
A. res.send()
B. res.end()
C. res.json()
D. res.stringify()
✅ Answer: C - What is a REST API?
A. Database
B. Server-side tool
C. Architectural style for APIs
D. JavaScript framework
✅ Answer: C - Which HTTP method is used to update resources?
A. GET
B. PUT
C. PATCH
D. Both B and C
✅ Answer: D - What does this middleware do?
app.use((req, res, next) => {
console.log(req.url);
next();
});
A. Logs requests
B. Blocks requests
C. Sends response
D. Loads files
✅ Answer: A
- How do you serve static files in Express?
app.use(express.static(‘public’));
A. True
B. False
✅ Answer: A
49. Which status code means unauthorized access?
A. 401
B. 403
C. 400
D. 404
✅ Answer: A
Code Less, Practice More – Crack Node.js Interviews Easily!
- What does CORS stand for?
A. Core Object Routing System
B. Cross-Origin Resource Sharing
C. Conditional Origin Request Setup
D. Content Optimization Routing Strategy
✅ Answer: B
Section 6: Asynchronous Programming – 10 MCQs
- What is a callback?
A. A variable
B. A function passed into another function
C. A loop
D. A file
✅ Answer: B - What is the purpose of async keyword?
A. Pause function
B. Make function synchronous
C. Enable use of await
D. Define a promise
✅ Answer: C - What does await do?
A. Blocks other processes
B. Waits for a promise to resolve
C. Speeds up execution
D. Caches response
✅ Answer: B - Which module is used for promises in Node.js?
A. promises
B. util
C. promiseHandler
D. No module needed
✅ Answer: D - Which function converts callback-based functions to promises?
A. util.promisify()
B. Promise.from()
C. awaitify()
D. callbackToPromise()
✅ Answer: A - What will this return?
Promise.resolve(5).then(x => console.log(x));
A. Error
B. 5
C. undefined
D. 0
✅ Answer: B
- Which of the following methods handles multiple promises?
A. Promise.combine()
B. Promise.all()
C. Promise.chain()
D. Promise.loop()
✅ Answer: B - Which Node.js function is asynchronous?
A. fs.readFile()
B. fs.readFileSync()
C. JSON.parse()
D. require()
✅ Answer: A - Which tool helps manage async operations better than callbacks?
A. setTimeout()
B. Promises
C. console.log()
D. fs module
✅ Answer: B - What is callback hell?
A. Multiple async functions nested inside each other
B. Infinite loops
C. Memory leak
D. Server crash
✅ Answer: A
Section 7: Error Handling & Advanced Topics – 10 MCQs
- How do you handle errors in async/await?
A. try…catch
B. throw error()
C. handle()
D. error()
✅ Answer: A - What does this code do?
throw new Error(‘Something went wrong’);
A. Creates a warning
B. Returns status code
C. Stops execution
D. Logs to console
✅ Answer: C
- What is the default port for Node.js apps (if not specified)?
A. 8080
B. 3000
C. 80
D. 5000
✅ Answer: B - Which method listens for server connections in Express?
A. connect()
B. server()
C. listen()
D. respond()
✅ Answer: C - Which of these is NOT an error handling middleware in Express?
A. (err, req, res, next)
B. function errorHandler(err)
C. (req, res)
D. customErrorHandler(err, req, res, next)
✅ Answer: C - What is the use of cluster module in Node.js?
A. Monitor servers
B. Create sub-processes
C. Run multiple instances of Node.js for load balancing
D. Schedule tasks
✅ Answer: C - Which command checks for outdated packages?
A. npm check
B. npm outdated
C. npm status
D. npm validate
✅ Answer: B - What will process.env.NODE_ENV usually be set to in production?
A. prod
B. development
C. production
D. env
✅ Answer: C - What does dotenv package do?
A. Connects to database
B. Stores credentials in .env file
C. Handles authentication
D. Validates HTTP requests
✅ Answer: B - Which of the following is a benefit of using Node.js?
A. Blocking I/O
B. Slow performance
C. Scalable and fast for I/O-heavy applications
D. Built-in GUI
✅ Answer: C
Smart Learning for Smart Coders – Node.js MCQs that Work.
Mastering these Node.js MCQs is a valuable step toward building a strong foundation in backend development, RESTful APIs, asynchronous programming, and server-side logic.
If you’re ready to elevate your career with hands-on projects and expert-led instruction, join our Node.js course in Gurgaon at Gyansetu and become industry-ready for high-demand backend and full-stack development roles.