1. Download
Go to nodejs to download the node.msi installation file package, which contains node.js and npm;
Just double-click node.msi, select the installation path and npm;
2. Setting environment variables
[The new version does not need to design environment variables, the software will automatically write environment variables]
Right-click on Computer (or My Computer) -> Advanced System Settings -> Environment Variables.
Create a new user variable.
Variable name: NODE_PATH
值:C:\Program Files\nodejs\node_modules
Note: the value is the nodejs installation directory
3. Test
1. Write the test code test.js
Just find a project folder and create a new service folder inside. My directory is E:\nodetest\service
Note: This path cannot contain Chinese
Then create a new UTF-8 encoded js file inside, the file name can be arbitrarily named, my file is called test.js
Add the following code to the js file
2. Run
Start the nodejs service, window key + R, enter cmd and press Enter
Enter node E:\nodetest\service\test.js in the command line window
Note: Do not add a semicolon at the end;
success
Enter http://127.0.0.1:8887/ in the browser and the result is as follows.