You can use node.js in two ways according to node.js website.
https://nodejs.org/en/
https://nodejs.org/en/
- npm (node package manager)
- Run javascript outside the browser
npm
Nowadays lots of js frameworks are available in market (e.g. Angular, backbone, require, react). If you want to use that framework in your application
you need to go to the respective website and download it. It is cumbersome job to download and configure it. What if I say there is one package manager
which will take care of your this problem you just need to give install instruction. It is like one central application which will install required js framework
on your behalf.
Note: If you are from .Net Background you must be thinking why npm when I already have Nuget Package manager. Nuget is good for server side assemblies and framework,
for client side npm is best. According to node.js site " npm, is the largest ecosystem of open source libraries in the world."
Below is the step to configure it.
Download and install node.js from its website (https://nodejs.org/en/)
Once you are done with installation, you will find node.js command window.
By default it store files in user directory.
If you have project which is using multiple js framework then it will be tedious job to install frameworks one by one. Instead of doing that you can create package.json file and it will get all js framework for you.
As you can see we created package.json file first and wrote all require js framework for our application and save it in our project folder. After that we just hit command npm install and it downloaded all packages for us.
Second use of node.js is it runs outside the browser.
I have created one javascript file and trying to run it from node command prompt let's see.