In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to build Node.js programming environment on linux". In daily operation, I believe many people have doubts about how to build Node.js programming environment on linux. Xiaobian consulted all kinds of information and sorted out simple and easy to use operation methods. I hope to answer the doubts of "how to build Node.js programming environment on linux"! Next, please follow the small series to learn together!
Step 1: Install Node.js
1. Execute the following command to download the installation package for Node.js.
wget https://npm.taobao.org/mirrors/node/v12.4.0/node-v12.4.0-linux-x64.tar.xz
2. Execute the following command to extract the Node.js installation package:
tar -xvf node-v12.4.0-linux-x64.tar.xz
3. Rename the Node.js installation directory by executing the following command:
mv node-v12.4.0-linux-x64/ /usr/local/node Step 2: Configure Node.js
1. Execute the following command to add the executable directory of Node.js to the system environment variables:
echo "export PATH=$PATH:/usr/local/node/bin" >> /etc/profile
2. Execute the following command to make the newly configured Node.js environment variable take effect immediately:
source /etc/profile
3. Execute the following command to view node and npm versions separately.
node -vnpm -v
Step 3: Test the Node.js environment
1. Create a test file using the vim command.
vim HelloWorld.js
2. Write the following code in the HelloWorld.js file.
var http = require('http');http.createServer(function (request, response) { response.writeHead( 200, { 'Content-Type': 'text/plain' }); response.end('Hello World\n');}).listen(8080);console.log('Server started');
3. Run the HelloWorld.js file by executing the following command:
node HelloWorld.js
4. Open a browser and type http://:8080 in the address bar, for example http://127.0.0.0:8080.
If the following interface is returned, it means success.
At this point, the study of "how to build a Node.js programming environment on linux" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
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.