Write Java code, encounter problems first to find the relevant Third-party APIs, has become a habit, Java Third-party API is really too much. But also do not envy Java,node.js also many, see the official website introduction:
The bottom of the official document is Appendix 1:recommended Third-party Modules, here is an introduction to the third party module, the first: There are, many third parties Modules for Node. At the time of writing, August, the master repository of modules is the wiki page. Open this link and you'll find quite a few third-party modules, hundreds of them.
To install the use of these modules requires the NPM (Node Package Manager) tool, the tool Node.js has been integrated, and this tool gives me a feeling like maven. Open the command line, perform npm-h (usually the command-line application can view help like this, or/?,--help), and the result is as follows:
The install and uninstall commands are found, and this should be the command to install and uninstall. Specific help can be found according to the following instructions
NPM install-h results are as follows:
This help is relatively simple, specific can be used
The NPM help install results are as follows:
The page has a very detailed description of the command. Uninstall also uses the above method.
Usually online see installation is used in this way NPM install Connect, that is NPM install <name>. So why just give name it can be installed, where the installation address AH.
The install document mentions a <name>@<version> that's published on the Registry with (c)
Then look at the following registry instructions, the document below see also link
The following paragraph in the registry document to resolve packages by name and version, NPM talks to a registry website
That's implements the COMMONJS Package Registry specification for reading info.
You can see that the name is resolved by it, the address is where, there is a sentence below
The registry URL is supplied by the Registry config parameter. The "I" (1) for more on managing NPM ' s configuration.
We're looking at the Config (1) Link, looking at the Config document, which is a global setting with the following passage in the document:
Registry Default:https://registry.npmjs.org/type:url
The base URL of the NPM package registry. See this default address, this is from here. This is the official address:
The official public NPM registry was at http://registry.npmjs.org/, It's powered by a CouchDB database at http://isaacs.ir Iscouch.com/registry.
Basically understand.
When you look at the installation, Cmd enters NPM help NPM to view the NPM documentation, which is described in this section:
Folders (1) to learn about where NPM puts stuff.
In particular, NPM has two modes of Operation:global mode:
NPM installs packages into the install prefix at Prefix/lib/node_modules and bins are installed in Prefix/bin. Local mode:
NPM installs packages into the current project directory, which defaults to the current working directory. Packages are installed To./node_modules, and bins are installed to./node_modules/.bin.
Local mode is the default. Use--global or-g on any command to operate in global mode instead. The meaning is very simple, I do not translate, click folders (1) Link, view folders document, have the following content:
Local Install (default): Puts stuff in./node_modules to the current package root. Global Install (WITH-G): puts stuff in/usr/local or wherever node is installed. Install it locally if you are going to require () it. Install it globally if you are going to run it in the command line. If you are need both, then install it in both places, or using NPM link we typically use require (), so it is common to use local installations without global installation.
Below the document also has prefix Configuration, Node Modules, executables Three paragraph introduction, after seeing can have more concrete understanding, I did not say more.
See Express Official document, can confirm:
installation
$ NPM Install Express
Or to access the Express (1) executable Install globally:
$ NPM Install-g Express
Where to find the module I need, there is a website must mention, http://search.npmjs.org/, this is a bit like the http://mvnrepository.com/of Maven.
The following Third-party modules have been studied recently, each of which describes the following:
1. Upload file: node-formidable official website Https://github.com/felixge/node-formidable, the official website below has related introduction and API
2.http middleware: Connect (ExtJS the same home) provides a framework similar to the Java EE filter, providing many middleware, such as: log, static file server, seesion and other functions, official website https://github.com/ senchalabs/connect/, use or look at the source recommendation to see https://github.com/senchalabs/connect/tree/1.8.2, because the default home page is 2.0, the code has been rewritten, help document http:// senchalabs.github.com/connect/, its internal upload file function is to use the formidable
3.web Frame: Express provides a framework similar to struts, official website http://expressjs.com/, document Http://expressjs.com/guide.html, source https://github.com /visionmedia/express/, it is based on connect.
4.web Socket:Socket.IO official website http://socket.io/, source https://github.com/learnboost/socket.io/
5.mongodb:node.js Visit MongoDB, official website https://github.com/christkv/node-mongodb-native
First to formidable to do a installation test:
CMD switch to the working directory, mine is D:\WebSite,
Enter NPM List
Description The directory does not have anything installed
A file named Upload.js is built in the working directory, which reads as follows:
[JavaScript] view plain copy var formidable = require (' formidable '); Enter Node Upload.js
Run the error.
Start Setup Enter NPM install formidable, wait a minute.
The installation was successful. The Node_modules folder is generated under this directory.
Now you can use it, and then enter the node Upload.js
No error, proof of installation success can be used. About the implementation of the upload code, the next time to speak.