Top nodejs node and npm command line tools tutorials

You can also check other posts on npm command deprecate option is deprecated

Basics of Nodejs Server

Nodejs is a server platform for deploying web applications using javascript. Nodejs server is very famous in the current industry for asynchronous request processing. We can use nodejs for streaming-based applications. NodeJS is a free and open-source application to develop server-side applications.

Nodejs is popular because of its event-driven and modularity-based architecture.

Nodejs installation comes with node and node packaging manager (NPM) tools.
Npm is a node package manager, and command line for the nodejs runtime environment.

Everything is npm packages in Nodejs

How to find out the nodejs server version in the command line?

Use the node command-line tool to get the node version. Node command displays the output to console as shown below node command with option -v or —version. a node with option -v does not work, use a node with —version command

A:\nodework>node --version

v6.2.2

A:\nodework>node -v
v6.2.2


How to display out npm tool version of the nodejs server in the command line?

npm version displayed using the npm command-line tool. npm reports result to console as shown below

Npm version will be showing using the -v option or —version.

A:\nodework>npm --version
3.9.5


A:\nodework>npm -v
3.9.5

How to get the nodejs v8 server engine version in the command line?

Nodejs uses the google v8 javascript server engine internally. It is the main engine for the event-driven feature developed by the google chrome team. V8 server engine compiles javascript code to native machine code. This code executes in a browser as well as independent applications.

Similarly, V8 is also used in MongoDB.

A:\nodework>node -p process.versions.v8
5.0.71.52

How to install packages/dependencies in the nodejs environment?

Nodejs is for managing different modules and packages. Npm install is used to install packages

npm packages install locally or globally. Based on the need of the requirement, We can go in any way.

how to do npm package install locally?

npm command installs the packages locally by default. Npm, install command copy the package contents to a node_modules folder. To test whether the package is installed or not, the Check package name folder exists under the node_module folder and makes sure that packagename.json exists

npm install packagename

how to do npm package installed globally?

npm command uses -g option to install a package globally. package name contents shared under nodejs node_modules folder

npm install -g packagename

how to add packages using npm install —save option?

packages dependencies are not added to default under package.json in your application. By using —save option, dependencies are added to package.json under the application code

npm install  packagename --save

and the output will be like the below content in package.json

{
name:package,
version:0.1,
dependencies
{sub_dep:0.1
}}

List the local and global packages

Every application can be used in local and global packages


npm list  // list local packages
npm list -g  // list global packages

That’s all basic nodejs commands.