Node JS is Platform, not a Framework. It contains many components to develop, test and deploy Enterprise applications.
Node JS Components List:
Node JS Platform has a CLI (Command Line Interface) to run basic commands and also script files.
When we install Node JS Platform, by default we will get this component. We do not need to any extra configurations for this component.
We can observe “node.exe” file at NODSJS_HOME. It is also known as Node Platform CLI component.
How to access Node CLI:
Now we are able to see NODE CLI i.e. “>”, that means our Node JS Setup is working fine.
Here we can run basic Java Script commands one by one or entire Java Script files (*.js files) to test the basic functionality.
NPM stands for Node Package Manager. NPM is used to install, update, uninstall and configure Node JS Platform modules/packages very easily.
When we install Node JS Base Platform, it installs only few components, modules and libraries like Node CLI, NPM etc. From this point, we can use NPM to upgrade Node JS Platform with our required modules.
By default Node JS platform install NPM module. We can observe this at NODEJS_HOME\node_modules folder as shown below.
When we install any other required modules, we can observe new folders here. That means for each module or package, Node JS maintains a separate folder here.
We can observe “npm.cmd” in Windows environment at NODEJS_HOME. This command is used to run NPM component from command prompt.
NOTE: In simple words, Maven is used to build Java modules into jar files and NPM is used to create, install, install and update Node Modules.
To check npm version, run “npm -v command as shown in below image.
For example, npm install –g express
command is used to install Express Module.
Sl No. | Command Parts | Description |
---|---|---|
1. | -g | It tells install this module globally that is with all administrator permissions. |
2. | express | Express module or package unique name |
We will discuss in-detail about each module installation in coming posts.
When we install modules by using npm, it use two modes install at two difference locations.
Local Mode: When we install Node JS Platform, by default it uses Local Mode to install npm module in node_modules directory as shown in below screen shot.
Sample command for installing express module would be “npm install express“.
Global Mode: When we use npm command with –g option, it uses Global Mode to install modules as shown in below screen shot for “npm install –g express” command.
Here “express” module is installed with Global Mode.
“package.json” is plain text file in JSON format. It is used to manage our application required module dependencies. We should place this file in our application root folder.
It defines information like our application name, module dependencies, module versions etc. This configurations file is very important and requires more time to explain in detail. We will discuss it in detail with some examples in coming posts.
Sample package.json file;
{
"name" : "sampleapp",
"version" : "1.0.0",
"dependencies" : {
}
}
Node JS is more modular platform. Each functionality is implemented by a separate module or package. It has some core modules like npm, install, uninstall, update etc and rest all modules are third-party modules.
When we install Node JS Platform, by default only one module is installed i.e. npm module. We need to use “npm” command to install required modules one by one.
All Core or Default modules are installed at /lib folder as *.js files as show below. In our case this path refers to “D:\NodeJS.V.0.12.0\node_modules\npm\lib”.
Node JS has thousands of modules, but here we are going to provide some of the popular modules. We will discuss and provide some examples about these modules in coming posts.
While writing this post, Node JS Platform supports the following number of packages.
A full list of Node JS Platform’s packages or modules can be found on the NPM website https://npmjs.org/.
Some of the Node JS Modules are written in Java Script and some are in C/C++ Language.
As Node JS Platform became very popular to develop Data-Sensitive Real-time and Network applications, many companies have developed some tools and framework to ease and reduce the overhead of Node JS applications.
Category | Framework/Tools |
---|---|
IDE | Eclipse with node.js plugins, Jetbrains Webstorm, Cloud9 IDE, Visual Studio Node JS Toolkit |
Database | Mongoose for MongoDB |
UI Build Tools | Grunt, Yeoman, Gulp |
CLI | Node CLI, grunt-cli |
Authentication | Passport.js |
UI Library Management | Bower |
UI Frameworks | Backbone.js, Angular.js, Ember.js |
Layout Frameworks | Twitter Bootstrap Framework |
Template Engine | Jade, EJS, Hogan.JS |
CSS Engine | Stylus, LESS, Compass |
Unit Testing Frameworks | Jasmin, Node Unit |
We will try to use some of these frameworks and tools to develop our Node JS examples in coming posts.
https://www.journaldev.com/7423/node-js-components-modules-npm-install-update-uninstall-example
Node JS is Platform, not a Framework---Node JS Platform Components
原文:https://www.cnblogs.com/feng9exe/p/12187736.html