Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure Node.js on Ubuntu

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to configure Node.js on Ubuntu". The content in the article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "how to configure Node.js on Ubuntu".

I. basic system installation

Node runs perfectly on all Linux,Macintosh,Solaris systems, and Ubuntu is a good fit for linux distributions. This is why we are trying to install Node.js on ubuntu 15.04. of course, we can use the same steps to install it on 14.04.

1. System resources

The basic system resources required for Node.js depend on your architectural needs. This tutorial will be done on a server with 1GB memory, 1GHz processor and 10GB disk space, with minimal installation, without the need to install a Web server or database server.

two。 System update

Before we install Node.js, it is recommended that you update the system to the latest patches and upgrade packages, so log in to the system and run the following command using the superuser:

# apt-get update

3. Installation dependency

Node.js only needs some basic system and software functions on your server, such as' make', 'gcc' and' wget'. If you haven't already installed them, run the following command to install them:

# apt-get install python gcc make gaming + wget

Download the latest version of Node JS v4.0.0

Visit the link Node JS Download Page to download the source code.

Nodejs download

Copy the link to the latest source code and download it with wget, with the following command:

# wget https://nodejs.org/download/rc/v4.0.0-rc.1/node-v4.0.0-rc.1.tar.gz

After the download is complete, use the command tar to extract:

# tar-zxvf node-v4.0.0-rc.1.tar.gz

Wget nodejs

Third, install Node JS v4.0.0

You can now start compiling Node.js using the downloaded source code. Before starting compilation, you need to change to the unzipped directory of the source code on ubuntu server and run the configure script to configure the source code.

Root@ubuntu-15:~/node-v4.0.0-rc.1#. / configure

Installing NodeJS

Now run the command 'make install' to compile and install Node.js:

Root@ubuntu-15:~/node-v4.0.0-rc.1# make install

The make command takes a few minutes to compile and wait quietly for a while.

Verify the installation of Node.js

Once the compilation task is complete, we can begin to verify that the installation is OK. We run the following command to confirm the version of Node.js.

Root@ubuntu-15:~# node-vv4.0.0-pre

Running node without arguments from the command line will enter REPL (Read-Eval-Print-Loop, read-execute-output-loop) mode, which has a simplified version of the emacs line editor through which you can run JS interactively and view the results.

Node version

Fifth, write the test program

We can also write a very simple terminal program to test whether the installation is successful and working properly. To do this, we will create a "test.js" file that contains the following code, as follows:

Root@ubuntu-15:~# vim test.jsvar util = require ("util"); console.log ("Hello! This is a Node Test Program");: wq!

Now to run the above program, run the following command on the command line.

Root@ubuntu-15:~# node test.js

Node Program

Running the above program in an environment where Node JS is successfully installed will get the output shown above on the screen. The program loads the class "util" into the variable "util", and then runs the terminal task with the object "util". The command console.log acts like cout in C++.

Thank you for reading, the above is the content of "how to configure Node.js on Ubuntu", after the study of this article, I believe you have a deeper understanding of how to configure Node.js on Ubuntu, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report