Introduction:
Node.js is a cross-platform environment
and library for running JavaScript applications which is used to create
networking and server-side applications.
Steps:
To
install and setup an environment for Node.js, you need the following two
software’s available on your computer:
- Text
Editor (Notepad or Notepad++)
- Node.js
Binary installable
Download Node.js:
You can download the latest version of
Node.js installable archive file from https://nodejs.org/en/
After downloading the Node.js install
it in your machine. Node.js Console: The
Node.js console module provides a simple debugging console similar to
JavaScript console mechanism provided by web browsers. There are three console methods that
are used to write any node.js stream:
- console.log()
- console.error()
- console.warn()
Basic Commands used in Command prompt: 1.
CD(Change
Directory): To change the directory. (cd path name – to generate directory
and cd\ - is to clear the directory). 2.
node
[file name].js: To debug or to execute the program. 3.
npm –v,--version: It is used to print node's version. 4.
npm
–h,--help: It is used to print node command
line options. 5.
npm -e, --eval: It evaluates the following argument as
JavaScript. The modules which are predefined in the REPL can also be used in
script. 6.
npm -p, --print: It is identical to -e but prints the
result. 7.
npm
-c, --check: Syntax check the script without
executing. 8.
npm -r, --require: It is used to preload the specified
module at startup. It follows require()'s module resolution rules. Module may
be either a path to a file, or a node module name. 9.
npm install [module name]: To install the required modules.
10.
Ctrl+C : Exit from debugging.
|