Prev Next

Web / NodeJS

Could not find what you were looking for? send us the question and we would be happy to answer your question.

1. Write the "Hello World" program using node.js.

/* Hello World! program using Node.js */
console.log("Hello World!");

2. What is Node.js?

Node.js is a powerful server side JavaScript based framework/platform built on Google Chrome's JavaScript V8 Engine.

3. Practical uses of node.js.

It enables the development of I/O intensive web applications like video streaming sites, single-page applications (SPA) and other web applications.

4. Is Node.js open source?


5. What type of Applications that node.js is not recommended for?

Application that involves cpu processing.

6. What is npm?

npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update the code that you're sharing.

7. Find the version of an installed npm package.

Use npm list for local packages or npm list -g for globally installed packages.

To find the version of the particular package given that the package name is known, use the command npm list package-name.

8. what is transpiling?

Transpiling refers to the process of taking source code written in one language and transforming into another language that has a similar level of abstraction.

9. Mention few logging libraries that you can use in your nodeJS project.

The below logging npm libraries are available for NodeJS projects.

  • Log4js,
  • Winston,
  • debug,
  • and Bunyan.
10. How do I enable gzip compression for my Node.js express responses?

Use the compression middleware for gzip compression in your Express app. Gzip compressing decrease the size of the response body and hence increase the speed of a web app.

First, install the npm package in your project for compression:

$ npm i compression --save

You can use the module in your application.

var compression = require('compression')
var express = require('express')
var app = express()

11. What is NestJS?

NestJS is a progressive Node.js framework for building efficient, reliable and scalable server-side applications.

12. What is the inspector module in NodeJS?
  • Core module in Node.JS.
  • Uses the Chrome DevTools (CDT) protocol.
  • Can connect to local or remote V8 engine.
13. Difference: npm vs npx.

Npm is a tool that use to install packages. Npx is a tool that use to execute node packages. NPX comes bundled with the NPM.

14. Compare npm vs yarn.

Both npm and Yarn are great package managers for Node.js and Javascript. Yarn was built by Facebook to solve major problems they faced with npm, such as the slower installation of packages and to address few security issues in npm.

Parallel installation of packages: Yarn installs packages in parallel, thus increasing performance and speed. NPM waits for a package to be fully installed before installing another package.

Automatic Lock file generation: Yarn automatically adds a yarn.lock file when dependencies are added to use the version from package.json. NPM doesn't create the lock file by default.

Security: NPM automatically executes a code that allows the other packages to get included into the fly, thus resulting in several vulnerabilities in the security system. On the other hand, Yarn installs those files which are only from the yarn.lock or package.json files.

Command for npmyarn
Install dependencies from package.jsonnpm installyarn
Install packagenpm install [package]yarn add [package]
Install dev dependencynpm install --save-dev [package]yarn add --dev [package]
Uninstall packagenpm uninstall [package]yarn remove [package]
Update packagenpm update [package]yarn upgrade [package]
Install package globalnpm install --global [package]yarn global add [package]
Uninstall package globalnpm uninstall --global [package]yarn global remove [package]
Nativescript interview questions

Comments & Discussions