1. Download nodejs from the official website and select the one on the left.
2. Select the file, right-click and click extract here to decompress
3. Enter the bin directory, right-click and select properties, the decompressed file can be placed anywhere in the system. Copy the path in the location
4. Add the path. Enter the .bashrc file and add the path in the location in step three at the end.
6. Enter source .bashrc in the terminal, press Enter, and then output the path: echo $PATH to check whether the path has been added successfully.
#7. Check whether nodejs is successfully installed. Right-click in the js file directory, then click open in terminal, enter the terminal, enter the node file name (the file name was qishuixian.js when I installed it)
consloe.log("1111")
8. Test in the browser: server.js source code:
var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type':'text/html;charset=utf-8'}); if(request.url!=="/favicon.ico"){ console.log('访问'); response.write('hello,world'); response.end('你好,世界'); } }).listen(8000); console.log('Server running at http://127.0.0.1:8000/');
All of the above This is the graphic tutorial for installing nodejs in the Linux environment introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!
For more graphic tutorials on nodejs installation in Linux environment, please pay attention to the PHP Chinese website!