In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the method of configuring and installing the node.js environment under the windows system". In the daily operation, I believe that many people have doubts about the method of configuring and installing the node.js environment under the windows system. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about the configuration and installation of the node.js environment under the windows system. Next, please follow the editor to study!
Step 1: download the installation file
Download address: official website https://nodejs.org/en/download/
What's used here is
Step 2: install nodejs
When the download is complete, double-click
Node-v6.9.1-x64.msi, start installing nodejs, which is installed under c:\ program files\ nodejs by default
Step 3: install the relevant environment
Open the c:\ program files\ nodejs directory and you will find that it comes with npm. You can install it directly with npm.
Open windows with dos window win+r, enter cmd, and enter enter
Type the command: cd c:\ program files\ nodejs
Now begin to install the relevant environment
Type the command: npm install express-g enter and wait for express.
Type the command: npm install jade enter to wait for the installation of jade.
Type the command: npm install mysql enter to wait for the installation of mysql.
. What components to install depends on the building requirements of the environment
By default, the above components are installed in the c:\ program files\ nodejs\ node_modules folder, which is also the automatic lookup path for nodejs-related components.
Step 4: create a project
If you find that there are no express and express.cmd files in the c:\ program files\ nodejs directory after installing the above components, execute the command npm install express-generator
(because the default installation of express is the latest version, it is already the version of 4.x.x. In the latest version of express4.0+, command tools are separated, so express-generator must be installed)
Now there is express.
The express command only works when installed globally!
So use npm install express-g when installing express
Or modify the global path directly:
Npm config set prefix "c:\ program files\ nodejs"
Npm config set cache "c:\ program files\ nodejs\ cache" (set up the cache directory first)
Type: express myapp (myapp is a random project name)
You will find an extra c:\ program files\ nodejs\ myapp directory
By default, it is automatically created in
Copy node_modules to myapp
After setting up the environment, let's do a demo test!
Create a new helloworld.js under myapp
Var http = require ("http"); http.createserver (function (request, response) {response.writehead (200,{ "content-type": "text/plain"}); response.write ("hello world"); response.end ();}) .customers (8888); console.log ("nodejs start listen 8888 port!")
Go to the node.js command prompt command window and go to the c:\ program files\ nodejs\ myapp directory
Type node helloworld.js
Open the address
Discovery output:
Hello world
Global mode and local mode installation issues are resolved:
Global mode:
After installing express and express-generator, go to the path:
C:\ program files\ nodejs generates two files, express and express.cmd.
Local mode:
After installing express and express-generator, there are no express and express.cmd files generated in the path: d:\ tools\ nodejs. And in the path:
Under c:\ program files\ nodejs\ node_modules, there is a .bin (generated when installing express-generator) that contains two files, express and express.cmd.
Then add: C:\ program files\ nodejs\ node_modules\ .bin to the system environment variable path
Try to execute again:
C:\ program files\ nodejs > express-v
At this point, the study of "the method of configuring and installing the node.js environment under the windows system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.