1. What is NPM?
NPM (Node Package Manager) manages packages for Node.js. It provides an online registry for open-source modules and a CLI tool to install, update, or remove packages.
npm install express
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Google · Node Js
Practice Node Js questions specifically asked in Google interviews – ideal for online test preparation, technical rounds and final HR discussions.
Questions
11
Tagged for this company + subject
Company
View company-wise questions
Subject
Node Js
Explore topic-wise practice
Go through each question and its explanation. Use this page for targeted revision just before your Google Node Js round.
NPM (Node Package Manager) manages packages for Node.js. It provides an online registry for open-source modules and a CLI tool to install, update, or remove packages.
npm install express
For complete preparation, combine this company + subject page with full company-wise practice and subject-wise practice. You can also explore other companies and topics from the links below.
A callback is a function passed as an argument to another function, executed once a task completes. It prevents blocking operations and allows asynchronous execution. However, deeply nested callbacks can lead to 'callback hell'.
fs.readFile('file.txt', (err, data) => { if (err) throw err; console.log(data.toString()); });Node.js uses Google’s V8 engine because it compiles JavaScript directly into machine code for high performance. It supports just-in-time (JIT) compilation, making Node.js fast and efficient for both server and network operations.
WASI (WebAssembly System Interface) allows WebAssembly modules to run in non-browser environments like Node.js. It provides sandboxed access to files and environment variables for better security and performance.
Tracing collects information about function calls and system events to analyze performance. Node.js’s built-in tracing API and tools like Chrome DevTools help identify bottlenecks and optimize runtime behavior.
Passport.js is a flexible authentication middleware for Node.js. It supports local logins and social logins (Google, Facebook, GitHub). It simplifies user authentication by using modular strategies.
const passport=require('passport');
app.post('/login',passport.authenticate('local'),(req,res)=>res.send('Logged in'));Yes. You can run `node inspect app.js` to debug applications. The built-in debugger allows step-by-step execution, variable inspection, and breakpoints using Chrome DevTools or VSCode integration.
node inspect index.js // open chrome://inspect for debugging
CI/CD automates testing, building, and deployment. CI ensures code integrity, while CD automates releases to production. Together, they reduce manual errors and accelerate delivery.
Docker containers isolate app environments and dependencies, ensuring consistent deployments. You can scale containers easily using Docker Compose or Kubernetes.
FROM node:18 WORKDIR /app COPY . . RUN npm install CMD ['npm','start']
Common strategies include in-memory cache (Node-cache), distributed cache (Redis), and HTTP-level caching using ETags or Cache-Control headers. Caching reduces repeated database hits and speeds up response times.
const cache=new Map();
function getUser(id){
if(cache.has(id)) return cache.get(id);
const user=db.find(id);
cache.set(id,user);
return user;
}The DNS (Domain Name System) module provides methods to resolve domain names to IP addresses. It can perform both asynchronous lookups and direct OS-level resolution using `dns.lookup()` and `dns.resolve()`.
const dns=require('dns');
dns.lookup('google.com',(err,addr)=>console.log(addr));