Note: This article installs the system for mac,windows and other systems to download the corresponding installation package, Mac download after the installation package for the APK file, Windows as an MSI file.
Installation
1. Download MongoDB installation package on the Internet, official website
2. Double-click the download file, follow the steps to install it, and then you can use the node and NPM commands once the installation is complete.
3. Open terminal input node-v, the terminal will prompt to install the node version.
The 4.NODEJS operating environment was successfully installed.
Common directives:
npm Install modulenames: Installing the Node module
After installation, a node_modules directory is created, and the individual node modules are installed in the directory.
Node installation is divided into global mode and local mode.
Normally it will run in local mode and the package will be installed into the local node_modules directory of your application code.
In global mode, the node package will be installed under Node_modules under node's installation directory.
The Global installation command is $NPM install-g modulename.
Learn to use $NPM set Global=true to set the installation mode, $NPM get global to see the installation mode currently in use.
npm View Modulenames: View the Package.json folder of the node module
Note: If you want to view the contents of a tag under the Package.json folder, you can use $NPM view ModuleName labelname
NPM list: View the installed node packages in the current directory
Note: The node module search starts at the current directory where the code executes, and the search results depend on the content under Node_modules in the currently used directory. The NPM list parseable=true can be used in the form of a directory to present all node packages currently installed
NPMHelp: View the assistance commands
npm View moudlename dependencies: View package dependencies
npm View ModuleName repository.url: View the source file address of the package
NPM View ModuleName engines: View the version of node that the package depends on
npm Help folders: View all the folders used by NPM
NPM rebuild ModuleName: Rebuild after changing package contents
NPM outdated: Check if the package is obsolete, this command lists all outdated packages, and updates the package in a timely manner
npm Update modulename: Updating the node module
npm Uninstall Moudlename: Uninstalling node module
To access the JSON folder for NPM:
$ NPM Help JSON : This command opens a Web page by default and may not open as a Web page if you change the default open program.
$ NPM Search PackageName: Verify that a package name already exists
NPM init: Boot creates a Package.json file, including name, version, author, etc.
NPM root: View the installation path of the current package,-G view the installation path of the global package
Simple Server Building Learning materials
Node Getting Started Tutorial
Node Chinese documentation Manual
1.Node server-side listening ports and open port processing events are required to introduce an HTTP module. The additional module file method introduced in node is: Require (module name).
In the 2.Node server simple processing also need to introduce the module has FS (file operation module), URL (path processing module) and so on.
Code
Service.js
//introducing the HTTP modulevarHTTP = require (' http ');//Introducing the FS modulevarFS = require (' FS ');//Introducing the URL modulevarurl = require (' URL '));//turn on the local HTTP service and listen for the appropriate port numberHttp.createserver (function(req,res) {//get the host address in the Requset informationvarhostname =Req.headers.host;//Get Pathnamevarpathname =Url.parse (req.url). Pathname;//determine if the address is a domain name (simple route)if(Pathname = = = '/')) {Readfileandresponse ('/index.html ', res);}). Listen (port);//read the file and return to responsefunctionReadfileandresponse (pathname,response) {//determine if a file existsFs.readfile (PATHNAME.SUBSTR (1), ",function(err,data) {//file does not exist or read error returned 404, and print page not foundif(Err) {Response.writehead (404); Response.End (' Page not found ');}Else{//The read successfully returns the corresponding page informationResponse.End (data);}});}
1. Open the terminal and go to the same directory where the Service.js is located.
Note: Not the service with the directory execution will be successful, but according to the configuration of the page and directory distribution, easy to appear css and JS style can not be displayed.
2. Run node service.js.
3. In the browser, enter: 127.0.0.1: Port number OK, the page successfully points to inde.html.
Web server: URL/Public IP: Port number, it can be accessed by the external network.
Node installs and builds a simple server