Linux mint install nodejs

How To Install Node.js on Linux Mint 21/20/19

Node.js is a platform built on Chrome’s V8 JavaScript engine. Nodejs can be used for easily building fast, scalable network applications. Latest version node.js ppa is maintaining by its official website. Also, the NVM (Node Version Manager) provides you an option to install a specific version or any number of Node.js versions for the logged-in user.

How to Install Node.js on Linux Mint

This quick how-to guide provides you with two methods to install Node.js & NPM on Linux Mint 21, 20, and 19 Linux systems.

Method 1 – Installing Node.js with Official PPA

First of all, you need to node.js PPA in our system provides by Nodejs official website. We also need to install the python-software-properties package if not installed already. You can choose either to install the latest Node.js version or the LTS version.

For Latest Release

sudo apt-get install curl python-software-properties software-properties-common curl -sL https://deb.nodesource.com/setup_19.x | sudo bash - 

For LTS Release

sudo apt-get install curl python-software-properties software-properties-common curl -sL https://deb.nodesource.com/setup_18.x | sudo bash - 

For this tutorial, I have added the latest release Apt repository on my Linux Mint system. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.

sudo apt-get install nodejs 

Method 2 – Installing Node.js with NVM

NVM provides a shell script for the installation on the Linux system. So, execute the installer script with the below commands. This will install the nvm command on your system.

sudo apt install curl curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 

Now, load the nvm environment in the current shell with the below command.

NVM is successfully installed on your system. Now you can install any node.js version with the help of NVM.

You can run the above command with different 2 versions to install any number of Node.js on your Linux Mint systems. For example, you can use nvm install 17 or nvm install 12.18 , etc.

Читайте также:  Linux найти все файлы новее

The systems have multiple node.js versions installed, can use the below command to set any installed node.js version as an active version.

You can find detailed instruction’s about the node.js installation in our previous tutorials. Find more details about Node.js installation via NVM.

How to Check Default Node.js Version

After completing the installation process of node.js, Let’s check and verify the installed version. You can find more details about the current version on node.js official website.

node -v  v19.2.0

Also, check the version of NPM.

npm -v  8.19.3

Step 4 – Create A Demo Web Server (Optional)

This is an optional step. If you want to test your node.js install. Let’s create a web server with “Hello World!” text. Create a file http_server.js

and add the following content

var http = require('http'); http.createServer(function (req, res) < res.writeHead(200, ); res.end('Hello World\n'); >).listen(3000, "127.0.0.1"); console.log('Server running at http://127.0.0.1:3000/');

Now start the web server using the command.

node http_server.js  Server running at http://127.0.0.1:3000/

Источник

How to Install Node.js on Linux Mint 21

Node.js is an open-source, asynchronous backend JavaScript runtime platform. It’s a powerful cross-platform runtime to build server-side projects in JavaScript language. Its non-blocking, I/O model feature makes it a more efficient, powerful, and fast environment.

Node.js has unlimited features but some of the most nominated that make it a JS developer’s choice are mentioned here. It comes with the MIT license having a single threaded model. It is asynchronous which means it never waits for the previous API’s response and outputs the data in chunks (no buffering).

Install Node.js on Linux Mint 21

To install Nodejs on Linux Mint 21 system, follow the steps mentioned below:

Step 1: Update the system’s repository with the help of the given command to upgrade all packages up-to-date:

Step 2: In this step, you are required to install all the dependencies as they are prerequisite of it; so, execute the command given below:

$ sudo apt install software-properties-common apt-transport-https ca-certificates gnupg2 curl build-essential

Step 3: Once you installed all the required dependencies, run the mentioned command to get Node-source repository in your system:

Step 4: Now you can install the Node.js application on Linux Mint 21 system after successfully set node source repository:

Step 5: Execute the following command to verify installed of Node.js version on system:

Test Node.js on Linux Mint 21

Create a simple JavaScript file using nano editor and type a simple program in it:

const http = require ( ‘http’ ) ;
const port = 3000 ;
const server = http.createServer ( ( req, res ) = > {
res.writeHead ( 200 , { ‘Content-Type’ : ‘text/plain’ } ) ;
res.end ( ‘Hello This is LinuxHint ! and I am Sam\n’ ) ;
} ) ;
server.listen ( port, ( ) = > {
console.log ( ` Listening Port $ ` ) ;
} ) ;

Save this program on the editor and open any browser to see the output. For this run the command given below in the terminal. This would start running a web server on local port 3000:

To verify successful installation of Nodejs, type in browser:

Читайте также:  Присоединение linux к домену

How to Remove Node.js from Linux Mint 21

To uninstall Node.js from the Linux Mint 21 system, the mentioned command would be executed in terminal:

Conclusion

Node.js is an open-source JavaScript runtime used to create JavaScript based projects. It is popular among developers who wish to build applications in a non-blocking environment.

In this article, we have mentioned in-depth details about the installation process of Node.js on the Linux Mint 21 system. We have also run a test file to show its web server working. Moreover, we have also mentioned the command to uninstall it.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.

Источник

How To Install Node.js on Linux Mint

Need to install a Node.js in Linux Mint? If so, I’ll show you two ways of installing Node.js on Linux Mint. The two ways are:

Solution 1: Install Node.js from repositories in Linux Mint

Step 1.1: Update packages and install Node.js

It’s a good practice before any installation from the repositories to update the packages. This can be done by:

Then you can install latest available Node.js by next command:

You will need to enter your root password.
Once the installation is complete you can check the version and verify the installation by:

Step 1.2: Install npm on Linux Mint

Many programs like JupyterLab will require npm to be installed in order to work. npm which stands for Node Package Manager can be installed on Linux Mint by:

Step 1.3: Upgrade Node.js which is installed from repositories

Often the installed Node.js version from the repositories will be outdated. If you need to upgrade Node.js to the latest version you can use module n .

The module n will take care for the upgrade of Node.js when it’s installed from PPA.

Then you can install the stable Node.js by:

Note 1: Depending on the OS, versions etc you may need to use sudo.

Note 2: There was a naming problem in the past for package node in Ubuntu. Which causes coexistence of node and nodejs commands in Linux Mint. Some programs will require nodejs others node . This should be handled with alias. You can check the output of the next command in order to find what versions do you have:

Solution 2: Install Node.js with nvm on Linux Mint

The second way which is better and my preferred one is installing nvm and using it to install node.

Step 2.1 Install nvm on Linux Mint

The nvm installation guide is available on : nvm Install & Update Script. So in order to install nvm on Linux Mint you can follow. Get the latest installation script from the page above:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash 

Note 1: this will download and run the script. If you like you can download it, review it and then install it.

Читайте также:  Runtime exec java linux

Note 2: You need to start a new terminal or run command: source ~/.bashrc in order to use nvm command.

Step 2.2 List Node versions with nvm

There are many different node packages available. In order to list all of them with nvm you can use command:

 v14.14.0 v14.15.0 (LTS: Fermium) -> v14.15.1 (Latest LTS: Fermium) v15.0.0 v15.0.1 v15.1.0 v15.2.0 v15.2.1 v15.3.0 v15.4.0 

Step 2.3 Install Node.js with nvm

When you find what version you like to use then you can install it by:

Step 2.4 Use multiple Node.js versions with nvm

It’s common to have several Node.js versions. The best way to manage them is with nvm . Local Node.js versions can be listed by:

 v12.18.3 -> v14.15.1 system default -> node (-> v14.15.1) iojs -> N/A (default) unstable -> N/A (default) node -> stable (-> v14.15.1) (default) stable -> 14.15 (-> v14.15.1) (default) lts/* -> lts/fermium (-> v14.15.1) lts/argon -> v4.9.1 (-> N/A) lts/boron -> v6.17.1 (-> N/A) lts/carbon -> v8.17.0 (-> N/A) lts/dubnium -> v10.23.0 (-> N/A) lts/erbium -> v12.20.0 (-> N/A) lts/fermium -> v14.15.1 

If you need to change the default one you can do it by:

Finally, check the Node version by:

By using SoftHints — Python, Linux, Pandas , you agree to our Cookie Policy.

Источник

Как установить Node.js на Linux Mint 20

hosting.energy недорогой хостинг сайтов

hosting.energy недорогой хостинг сайтов

В этом руководстве мы покажем вам, как установить Node.js на Linux Mint 20. Для тех из вас, кто не знал, Node.js — это платформа Javascript для программирования, которая позволяет пользователям очень быстро создавать сетевые приложения. Если вы используете Javascript как во внешнем, так и в серверном интерфейсе, это означает, что ваша разработка может быть более последовательной и разрабатываться в рамках одной и той же системы.

В этой статье предполагается, что у вас есть хотя бы базовые знания Linux, вы знаете, как использовать оболочку, и, что наиболее важно, вы размещаете свой сайт на собственном VPS. Установка довольно проста и предполагает, что вы работаете с учетной записью root, в противном случае вам может потребоваться добавить ‘ sudo ‘ к командам для получения привилегий root. Я покажу вам пошаговую установку Node.js на Linux Mint 20 (Ульяна).

Установите Node.js на Linux Mint 20 Ulyana

Шаг 1. Перед запуском приведенного ниже руководства важно убедиться, что ваша система обновлена, выполнив следующие apt команды в терминале:

sudo apt update sudo apt install curl build-essential

Шаг 2. Установка Node.js на Linux Mint 20.

Выполните следующую команду, чтобы установить пакеты snap dan Node.js:

sudo rm /etc/apt/preferences.d/nosnap.pref sudo apt install snapd sudo snap install node --classic

Выполните команду ниже, чтобы настроить репозиторий Nodesource в вашей системе:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

После добавления репозитория NodeSource самое время установить Node.js:

После завершения процесса установки node.js, давайте проверим установленную версию:

Поздравляю! Вы успешно установили Node.js . Благодарим за использование этого руководства для установки последней версии Node.js в системе Linux Mint. Для получения дополнительной помощи или полезной информации, мы рекомендуем вам проверить на официальном сайте Node.js .

Источник

Оцените статью
Adblock
detector