Spent a morning reading [reprint]node Getting Started» A comprehensive node. JS Tutorial
According to the inside of the demo itself manual implementation process or need to write questions, special finishing in this.
<1> Because the Node.msi installation package has automatically added system environment variables, you can run node Xxx.js anywhere in the path.
<2> Determine if 2 environment variables have been added
(1) One is the directory that adds node.exe on path C:\Program Files\nodejs, (added automatically)
(2) One is to increase the environment variable Node_path, the value is C:\Program files\nodejs\node_modules (the environment variable does not seem to be necessary.) )
But C:\Documents and settings\xxx\application data\npm This folder path must be required, manually established, otherwise the error occurs when you execute NPM:
Error:enoent, stat ' C:\USERS\ADMINISTRATOR\APPDATA\ROAMING\NPM.
<3> To install the module via NPM It is important to note that CMD switches to the destination folder where the project is located, such as installing the ' formidable ' module:
G:\Study\12.NodeJS\MyDemos\01.NodeJSBlog > NPM Install formidable
This will generate the \node_modules\formidable folder under the current project file.
<4> Upload a folder path problem
function upload (response, request) { Console.log ("Request handler ' upload ' was called."); var form = new Formidable. Incomingform (); Form.uploaddir = "./tmp/"; Add: Need to set the relative path of the upload folder console.log ("About to parse"); Form.parse (Request, function (Error, fields, files) { Console.log ("parsing done"); Fs.renamesync (Files.upload.path, "./tmp/test.gif"); Response.writehead ($, {"Content-type": "Text/html"}); Response.Write ("received image:<br/>"); Response.Write ("
At this point, the demo runs successfully, the file is uploaded and displayed successfully.
Nodejs Community
http://cnodejs.org/
http://cnodejs.org/
http://yuan.rednode.cn/
Finishing Node Getting Started» A comprehensive node. JS Tutorial-Problems with demo practice