This Node.js quiz contains 25 multiple-choice questions covering the runtime, npm, modules, file handling, asynchronous programming, events, streams, HTTP servers, and process APIs. Choose one answer for each question, then use the answer key to check your score and review the explanations.

How to Take This Node.js Multiple-Choice Quiz

  • Answer all 25 questions before opening the answer key.
  • Award yourself one point for each correct answer.
  • Read the explanation even when your answer is correct, because several questions distinguish similar Node.js APIs.
  • The quiz uses stable Node.js concepts and avoids questions tied to one short-lived release.

Node.js Runtime and npm Quiz Questions 1-5

  1. What is Node.js primarily used for?
    A. Running JavaScript outside a web browser
    B. Styling HTML pages
    C. Managing relational databases directly
    D. Compiling Java source files
  2. Which JavaScript engine executes JavaScript in Node.js?
    A. SpiderMonkey
    B. V8
    C. JavaScriptCore only
    D. ChakraCore only
  3. Which command runs a file named app.js with Node.js?
    A. npm app.js
    B. node app.js
    C. run node app.js
    D. javascript app.js
  4. Which command creates a package.json file using default answers?
    A. node init
    B. npm create package
    C. npm init -y
    D. npm package -y
  5. What is a primary purpose of package.json?
    A. To store only application output
    B. To describe project metadata, scripts, and dependencies
    C. To replace every JavaScript source file
    D. To configure the operating system firewall

Node.js Modules and Package Management Questions 6-10

  1. Which module specifier refers to Node.js’s built-in HTTP module?
    A. node:http
    B. node:web
    C. npm:http
    D. browser:http
  2. Which statement about Express is correct?
    A. Express is the JavaScript engine inside Node.js
    B. Express is a third-party web framework that can run on Node.js
    C. Express is a built-in replacement for npm
    D. Express is required to execute every Node.js file
  3. In a CommonJS module, which statement exports a value as the module’s main export?
    A. module.exports = value;
    B. module.import = value;
    C. require.exports(value);
    D. package.export(value);
  4. Which syntax imports readFile from node:fs/promises in an ECMAScript module?
    A. include readFile from "node:fs/promises";
    B. import { readFile } from "node:fs/promises";
    C. require import readFile;
    D. using readFile in "node:fs/promises";
  5. Which npm command installs a package as a development dependency?
    A. npm install package-name -D
    B. npm run package-name
    C. node install package-name
    D. npm remove package-name --dev

Node.js Process, Paths, and File System Questions 11-15

  1. Which expression returns the current working directory of the Node.js process?
    A. process.cwd()
    B. process.dir()
    C. path.current()
    D. fs.cwd()
  2. Where are environment variables commonly accessed in Node.js?
    A. global.environment
    B. process.env
    C. node.variables
    D. os.environment()
  3. Which path method safely combines path segments using the platform’s path separator?
    A. path.join()
    B. path.mergeFile()
    C. path.concatOnly()
    D. path.attach()
  4. What does fs.readFile() do when used with a callback?
    A. Reads a file asynchronously and later calls the callback
    B. Reads a file synchronously and returns its contents immediately in every case
    C. Deletes the file after reading it
    D. Converts the file into an HTTP response automatically
  5. In the conventional Node.js error-first callback pattern, what is the first callback argument?
    A. The successful result
    B. An error value, usually null when no error occurred
    C. The current process ID
    D. The callback execution time

Node.js Events, Buffers, and Streams Questions 16-20

  1. What is a Node.js Buffer commonly used for?
    A. Representing binary data in memory
    B. Defining CSS styles
    C. Creating SQL tables
    D. Replacing the event loop
  2. What is the main benefit of processing a large file with a stream?
    A. The entire file must always be loaded into memory first
    B. Data can be processed in chunks instead of loading everything at once
    C. The file is automatically converted to JSON
    D. Streams make every operation synchronous
  3. Which list contains the four commonly discussed Node.js stream types?
    A. Input, output, server, and client
    B. Readable, writable, duplex, and transform
    C. Binary, text, JSON, and XML
    D. Local, global, public, and private
  4. Which method registers a listener for an event emitted by an EventEmitter?
    A. emitter.on(eventName, listener)
    B. emitter.wait(eventName)
    C. emitter.read(eventName)
    D. emitter.callbackOnly(eventName)
  5. Which event is commonly used to receive chunks from a readable stream in flowing mode?
    A. data
    B. compile
    C. install
    D. route

Node.js Event Loop and HTTP Server Questions 21-25

  1. What is the event loop responsible for in a Node.js application?
    A. Applying browser CSS rules
    B. Coordinating callbacks and asynchronous work
    C. Installing all npm packages automatically
    D. Converting JavaScript into Java source code
  2. What can happen when a long CPU-intensive calculation runs synchronously on the main Node.js thread?
    A. It can block the event loop and delay other work
    B. It automatically runs in a browser tab
    C. It turns every callback into a Promise
    D. It clears all environment variables
  3. Which Node.js feature can run CPU-intensive JavaScript work on additional threads?
    A. worker_threads
    B. node:css
    C. package-lock
    D. EventTarget.preventDefault()
  4. In a server created with node:http, which method signals that the response is complete?
    A. res.end()
    B. res.stopNode()
    C. res.closePackage()
    D. res.finishServerFile()
  5. Which statement sets an HTTP response status code to 404 before the response is sent?
    A. res.statusCode = 404;
    B. res.error = "404";
    C. http.status(404);
    D. process.statusCode(404);

Node.js Quiz Answer Key and Explanations

QuestionAnswerExplanation
1ANode.js is a JavaScript runtime that executes JavaScript outside the browser, including on servers and command-line systems.
2BNode.js uses the V8 JavaScript engine to parse and execute JavaScript code.
3BThe node command followed by a file path runs that JavaScript file.
4Cnpm init -y creates package.json using default values instead of asking the interactive initialization questions.
5Bpackage.json records project information such as scripts, dependencies, package name, and version.
6Anode:http is the explicit built-in module specifier for Node.js’s HTTP API.
7BExpress is installed separately from npm and provides routing and web application features on top of Node.js.
8ACommonJS modules can assign the value exposed by require() through module.exports.
9BNamed ECMAScript module imports use braces around the imported binding.
10AThe -D flag is an alias for --save-dev and records the package under devDependencies.
11Aprocess.cwd() returns the directory from which the process is currently operating.
12BNode.js exposes environment variables through the process.env object.
13Apath.join() combines path segments and normalizes separators for the current platform.
14AThe callback form of fs.readFile() starts an asynchronous read and invokes the callback after completion or failure.
15BNode.js callbacks commonly place the error first and the successful result second.
16AA Buffer stores raw binary bytes, which is useful for files, network data, and other byte-oriented operations.
17BStreams handle data incrementally, which can reduce memory use for large inputs.
18BThe standard categories are readable, writable, duplex, and transform streams.
19AThe on() method attaches a listener that runs when the named event is emitted.
20AIn flowing mode, a readable stream emits data events as chunks become available.
21BThe event loop coordinates when callbacks and other scheduled work can run.
22ALengthy synchronous CPU work occupies the main JavaScript thread and prevents the event loop from handling other callbacks during that time.
23AThe worker_threads module supports parallel JavaScript execution for suitable CPU-intensive tasks.
24Ares.end() completes an HTTP response. It can optionally send the final response data.
25AAssigning 404 to res.statusCode sets the response status before headers are sent.

Interpret Your Node.js Quiz Score

ScoreSuggested next step
22-25You have a strong grasp of Node.js fundamentals. Continue with practical work involving streams, testing, error handling, and production application structure.
17-21Your foundation is sound. Review the explanations for missed questions and build a small HTTP or file-processing project.
11-16Revisit modules, npm, callbacks, the event loop, and core APIs before taking the quiz again.
0-10Start with Node.js runtime basics, command-line execution, package management, and simple asynchronous file operations.

Node.js Quiz Topics to Review After the Test

Use the official Node.js API documentation to review core modules and the Node.js learning guides for explanations of asynchronous programming, the event loop, package management, files, streams, and HTTP servers.

  • Modules: Compare CommonJS require() and module.exports with ECMAScript module import and export.
  • Asynchronous code: Practise callbacks, Promises, and async/await, including error handling.
  • Core APIs: Build small examples with node:fs, node:path, node:events, node:stream, and node:http.
  • npm workflow: Review dependencies, development dependencies, scripts, and the role of the lockfile.
  • Performance: Learn which operations block the event loop and when streams or worker threads are appropriate.

Frequently Asked Questions About the Node.js Quiz

Is this Node.js quiz suitable for beginners?

Yes. The first questions cover runtime and npm basics, while later questions introduce modules, files, streams, events, the event loop, and HTTP servers. Beginners can use the answer explanations as a study guide.

Does the quiz include Node.js questions with answers?

Yes. All 25 multiple-choice questions have an answer and a short explanation in the answer-key table.

Does this Node.js test cover Express.js?

The quiz includes one question that distinguishes Express from Node.js core. Express is a separate web framework, so a full Express.js quiz should additionally cover middleware, routing, request parameters, response methods, and error-handling middleware.

Which Node.js topics are most useful for interview preparation?

Common interview areas include the event loop, asynchronous I/O, callbacks and Promises, CommonJS and ECMAScript modules, streams, buffers, process APIs, error handling, npm, HTTP servers, and the effect of synchronous CPU-heavy work.

How can I practise after completing this Node.js quiz?

Create a small command-line program, read and write a file asynchronously, build an HTTP server, process a large file with streams, and add an npm script to run the application. These tasks turn the quiz concepts into practical skills.

Node.js Quiz Editorial QA Checklist

  • Confirm that every answer-key letter matches the corresponding Node.js multiple-choice option.
  • Keep CommonJS and ECMAScript module syntax clearly separated so learners do not combine incompatible examples.
  • Do not describe Express, third-party packages, or npm packages as built-in Node.js modules.
  • Check Node.js API names, capitalization, and method signatures against the official documentation before adding new questions.
  • Label any release-specific behavior when extending the quiz so stable fundamentals are not presented as universal across all Node.js versions.