Installing javascript on linux

Installing Node.js via package manager

Note: The packages on this page are maintained and supported by their respective packagers, not the Node.js core team. Please report any issues you encounter to the package maintainer. If it turns out your issue is a bug in Node.js itself, the maintainer will report the issue upstream.

Android

Android support is still experimental in Node.js, so precompiled binaries are not yet provided by Node.js developers.

However, there are some third-party solutions. For example, Termux community provides terminal emulator and Linux environment for Android, as well as own package manager and extensive collection of many precompiled applications. This command in Termux app will install the last available Node.js version:

Currently, Termux Node.js binaries are linked against system-icu (depending on libicu package).

Arch Linux

Node.js and npm packages are available in the Community Repository.

CentOS, Fedora and Red Hat Enterprise Linux

Node.js is available as a module called nodejs in CentOS/RHEL 8 and Fedora.

where corresponds to the major version of Node.js. To see a list of available streams:

For example, to install Node.js 12:

For CentOS/RHEL 7 Node.js is available via Software Collections.

Alternatives

These resources provide packages compatible with CentOS, Fedora, and RHEL.

Debian and Ubuntu based Linux distributions

Alternatives

Packages compatible with Debian and Ubuntu based Linux distributions are available via Node.js snaps.

Fast and simple Node.js version manager built in Rust used to manage multiple released Node.js versions. It allows you to perform operations like install, uninstall, switch Node versions automatically based on the current directory, etc. To install fnm, use this install script.

fnm has cross-platform support (macOS, Windows, Linux) & all popular shells (Bash, Zsh, Fish, PowerShell, Windows Command Line Prompt). fnm is built with speed in mind and compatibility support for .node-version and .nvmrc files.

FreeBSD

The most recent release of Node.js is available via the www/node port.

Install a binary package via pkg:

Or compile it on your own using ports:

Gentoo

Node.js is available in the portage tree.

IBM i

LTS versions of Node.js are available from IBM, and are available via the ‘yum’ package manager. The package name is nodejs followed by the major version number (for instance, nodejs12 , nodejs14 etc)

To install Node.js 14.x from the command line, run the following as a user with *ALLOBJ special authority:

Node.js can also be installed with the IBM i Access Client Solutions product. See this support document for more details

macOS

Download the macOS Installer directly from the nodejs.org web site.

If you want to download the package with bash:

Alternatives

Using Homebrew:

Using MacPorts:

Using pkgsrc:

Install the binary package:

Or build manually from pkgsrc:

n is a simple to use Node.js version manager for Mac and Linux. Specify the target version to install using a rich syntax, or select from a menu of previously downloaded versions. The versions are installed system-wide or user-wide, and for more targeted use you can run a version directly from the cached downloads.

See the homepage for install methods (boostrap, npm, Homebrew, third-party), and all the usage details.

If you already have npm then installing n and then the newest LTS node version is as simple as:

NetBSD

Node.js is available in the pkgsrc tree:

Or install a binary package (if available for your platform) using pkgin:

Nodenv

nodenv is a lightweight node version manager, similar to nvm . It’s simple and predictable. A rich plugin ecosystem lets you tailor it to suit your needs. Use nodenv to pick a Node version for your application and guarantee that your development environment matches production.

Nodenv installation instructions are maintained on its Github page. Please visit that page to ensure you’re following the latest version of the installation steps.

Node Version Manager is a bash script used to manage multiple released Node.js versions. It allows you to perform operations like install, uninstall, switch version, etc. To install nvm, use this install script.

On Unix / OS X systems Node.js built from source can be installed using nvm by installing into the location that nvm expects:

After this you can use nvm to switch between released versions and versions built from source. For example, if the version of Node.js is v8.0.0-pre:

Читайте также:  Windows server 2012 windows firewall что это такое

Once the official release is out you will want to uninstall the version built from source:

Windows

The nvs version manager is cross-platform and can be used on Windows, macOS, and Unix-like systems

To install nvs on Windows go to the release page here and download the MSI installer file of the latest release.

You can also use chocolatey to install it:

macOS,UnixLike

You can find the documentation regarding the installation steps of nvs in macOS/Unix-like systems here

Usage

After this you can use nvs to switch between different versions of node.

To add the latest version of node:

Or to add the latest LTS version of node:

Then run the nvs use command to add a version of node to your PATH for the current shell:

To add it to PATH permanently, use nvs link :

OpenBSD

Node.js is available through the ports system.

Using pkg_add on OpenBSD:

openSUSE and SLE

Node.js is available in the main repositories under the following packages:

  • openSUSE Leap 15.2: nodejs10 , nodejs12 , nodejs14
  • openSUSE Tumbleweed: nodejs16
  • SUSE Linux Enterprise Server (SLES) 12: nodejs10 , nodejs12 , and nodejs14 (The «Web and Scripting Module» must be enabled.)
  • SUSE Linux Enterprise Server (SLES) 15 SP2: nodejs10 , nodejs12 , and nodejs14 (The «Web and Scripting Module» must be enabled.)

For example, to install Node.js 14.x on openSUSE Leap 15.2, run the following as root:

Different major versions of Node can be installed and used concurrently.

SmartOS and illumos

SmartOS images come with pkgsrc pre-installed. On other illumos distributions, first install pkgsrc, then you may install the binary package as normal:

Or build manually from pkgsrc:

Node.js snaps are available as node on the Snap store.

Solus

Solus provides Node.js in its main repository.

Void Linux

Void Linux ships Node.js stable in the main repository.

Windows

Download the Windows Installer directly from the nodejs.org web site.

Alternatives

Using Chocolatey:

Using Scoop:

IBM® SDK for Node.js — z/OS® is available in two installation formats, SMP/E and PAX. Select the installation format that applies to you:

В© OpenJS Foundation. All Rights Reserved. Portions of this site originally В© Joyent.

Источник

Installation of Node.js on Linux

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js can be installed in multiple ways on your Ubuntu Linux machine. You can use Ubuntu’s official repository to install Node.js or another way to use NodeSource repository. Installation via NodeSource repository will allow you to choose latest version of Node.js.

Installing Node On Ubuntu 18.04 and 16.04: There are two methods Ubuntu official repository and NodeSouce repository to install Node.js on Ubuntu.

Install Node.js using Ubuntu official repository: Node.js is available in Ubuntu’s repository and you can easily install it using a few commands. Follow the steps below to install Node.js on your Ubuntu operating system.

  • Step 1: Open your terminal or press Ctrl + Alt + T.
  • Step 2: To install node.js use the following command:

sudo apt install nodejs


Step 3: Once installed, verify it by checking the installed version using the following command:

node -v or node –version

Note: It is recommended to install Node Package Manager(NPM) with Node.js. NPM is an open source library of Node.js packages.
To install NPM, use the following commands:

sudo apt install npm
npm -v or npm –version

Node and NPM will be successfully installed on your Ubuntu machine.

Install Node.js using NodeSouce repository: The latest version of Node.js can be installed from NodeSource repository. Follow the steps below to install the Node.js on your Ubuntu.

    Step 1: Open your terminal or press Ctrl + Alt + T and use the following commands to update and upgrade the package manager:

sudo apt-get update
sudo apt-get upgrade



Step 2: Install Python software libraries using the following command:

sudo apt-get install python-software-properties


Step 3: Add Node.js PPA to the system.

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

Note: Here, we are installing node.js version 10, if you want to install version 11, you can replace setup_10.x with setup_11.x.

Step 4: To Install Node.js and NPM to your Ubuntu machine, use the command given below:

sudo apt-get install nodejs


Step 5: Once installed, verify it by checking the installed version using the following command:

node -v or node –version
npm -v or npm –version

Источник

Установка JavaScript — JS: Настройка окружения

Для запуска кода на JavaScript необходимо скачать и установить Node.js.

Первый вариант — сделать это вручную разными способами из документации.

Второй вариант — использовать пакетный менеджер. Откройте терминал и выполните команду установки, соответствующую вашей операционной системе:

Ubuntu или Ubuntu on Windows

macOS

Интерактивный запуск кода

Теперь убедимся в том, что Node.js поставлена и работает. Вероятно, в некоторых операционных системах понадобится перезапустить терминал или даже перезагрузиться.

Откройте терминал и наберите в нем следующую команду:

Если все прошло удачно, самое время запустить код на JavaScript.

Запуск программы node запустит репл (REPL). Это среда, похожая на обычный терминал, только вместо Bash-команд в нее вводится код на JavaScript. С его помощью можно набрать строчку кода и тут же выполнить ее нажав Enter.

Такой способ работы очень хорошо подходит для быстрой проверки гипотез «а как работает эта штука?», а также для отладки и простых вычислений. Репл позволяет использовать переменные и запоминает предыдущий ввод:

Чтобы выйти из репла, нужно либо набрать .exit и нажать Enter, либо два раза нажать CTRL + C. После этого мы окажемся внутри обычной командной оболочки.

Разделяйте понятие репл nodejs и командная оболочка (например, bash). Когда мы набираем node, то запускается программа, которая не имеет никакого отношения к оболочке, в которой она запустилась. Любая попытка пользоваться этим реплом как обычной оболочкой приведет к разным синтаксическим ошибкам:

Пример установки и запуска Node.js на Ubuntu

Запуск кода из файлов

Для полноценной и удобной разработки репл уже не подходит, в этом случае код записывают в обычные текстовые файлы на компьютере разработчика. Какой для этого использовать редактор? На сегодняшний день самым распространенным и удобным редактором для кода считается VS Code. Скачайте его, установите и поизучайте интерфейс. У него много встроенных возможностей, которые расширяются плагинами.

Откройте редактор, создайте в нем файл с именем index.js и следующим содержимым:

VS Code имеет встроенные механизмы для запуска кода, но прямо сейчас, когда вы только учитесь, нужно уметь запускать код самостоятельно. Откройте терминал в той директории, где вы создали файл в редакторе и выполните команду:

Открыть доступ

Курсы программирования для новичков и опытных разработчиков. Начните обучение бесплатно.

  • 120 курсов, 2000+ часов теории
  • 900 практических заданий в браузере
  • 360 000 студентов

Наши выпускники работают в компаниях:

С нуля до разработчика. Возвращаем деньги, если не удалось найти работу.

Источник

How to Install Node.js from Linux Terminal

Node.js is an open-source, free, cross-platform JavaScript run-time environment which is responsible for executing JavaScript code on server. It allows developers to use JavaScript for server-side scripting — running scripts server-side to produce dynamic web page content before the page is sent to the user’s web browser. Consequently, Node.js represents a «JavaScript everywhere» paradigm, unifying web application development around a single programming language, rather than different languages for server side and client side scripts.

In this tutorial, I will show you how to install the latest Nodejs on Ubuntu 18.04, CentOS 7, and Arch Linux from the terminal.

There are several ways to install Node.js on Linux machine and we are going to cover them in this article.

  • Install using Node Version Manager (NVM)
  • Install using the Github source code clone
  • Install the Distro-Stable version of Node.js

Install using Node Version Manager (NVM)

NVM doesn’t work at the operating system level, instead it works at the level of a directory within your user’s home directory. It allows installing multiple, self-contained versions of Node.js without affecting the entire system.

Ubuntu 18.04

Before installing NVM we update OS with the following command

To use nvm, we must have curl, build-essentials libssl-dev packages installed on the system. To install them type

Once all prerequisites are available we install nvm with the following command

The script above clones the nvm repository to

/.nvm and also adds the source line to your profile (

/.bashrc). That means we need to source the profile file. To do so, type the following command

Now nvm functionalities and binaries are available for use and we can get list of available Node.js versions via the following command

Tail of output must look like the one below:

Choose the version you want to install and type the command below to install it.

After installing the desired version we can set that version as default Node.js version (in case you have multiple installations)

To check if version is installed and set to default successfully, just check Node.js version with the command below

The output of this command must show the installed version.

To update/install another version you can run:

Make sure to run the command with the version you want to install. After you can set the freshly installed version as your default with the following command:

To remove node.js version via nvm, first check if it’s not the current version with the command below

and run the following command to remove the desired version:

CentOS 7

The process of installation of nvm and node.js using nvm is the same as on Ubuntu 18.04 with few differences. Below you can find commands running which in the same order will install nvm, node.js and set the default version.

Source profile file (note that in CentOS it differs from the one in Ubuntu)

List available node.js versions

Install the desired version (make sure to change with the version you want to install)

Set as default node.js version

Check if installation and default setting are succeeded

To update/install another version you can run:

Make sure to run the command with the version you want to install. After you can set the freshly installed version as your default with the following command:

To remove node.js version via nvm, first check if it’s not the current version with the command below

and run the following command to remove desired version:

Install using the Github source code clone

To install Node.js using release from official Github repository we need to check make sure the make , gcc , g++ and python packages are installed on Ubuntu 18.04 machine. If there are missing packages, you can run:

On CentOS 7 all needed packages are preinstalled in OS. You can run OS update command to make sure they are latest versions:

The rest part of installation using GitHub repository’s official release is the same for both distributions.

Download the desired release (e.g. v6.2.1) from Github Repo using the following command:

Extract the content of the archive using the command below

Enter the directory with extracted files

and run the following command to compile

After compilation you can now install node.js using the following command:

The process of installation can take little bit longer this way. It depends on resources of your machine.

Install the Distro-Stable version of Node.js

In default repositories of Linux distributions, there are versions of Node.js and you can install them using any package manager of the distribution (apt for Ubuntu, yum for CentOS and etc. ). The main issue with this type of installation is that the versions available in official repositories may be outdated. For example, at the moment of writing this tutorial the latest version of Node.js in Ubuntu’s repositories is v8.10.0, and in CentOS epel-release repo the latest available version is v6.14.0. But using nvm we can install v10.0.0 at the same time. However, below you can find steps to install latest available stable version of Node.js for each distro.

Ubuntu 18.04

Before installing Node.js on your Ubuntu 18.04 machine, update you OS to the latest version. To do so, you can run:

Now you can install Node.js using the following command:

Also you can install npm (Node.js package manager) to install modules and packages. To install npm , run the command below:

After installation, you can check the version of Node.js (note that the executable from the Ubuntu repositories is called nodejs instead of node )

To update Node.js on Ubuntu 18.04 machine either update OS with the command:

or run install command. It will update the existing version if there are updates:

To remove Node.js from your Ubuntu 18.04 machine run the following command:

CentOS 7

To install Node.js on CentOS 7 machine using official repositories follow the steps below.

First, install epel-release repository on your machine using the following command:

This will allow you to install Node.js. To do so, you can run:

Check the installed version with the command below:

And finally you can install npm (Node.js package manager) using the following command:

To update Node.js on CentOS 7 machine either update OS with the command:

or run install command. It will update the existing version if there are updates:

To remove Node.js from your CentOS7 machine run the following command:

Arch Linux

To install Node.js on Arch Linux, use the following command:

To install npm, you can run:

To remove Node.js from Arch Linux typ:

Check if Node.js is working using script

To check if our installation (doesn’t matter which way) is successful and node.js is working properly, we are going to create very simple «Hello World» app and check if everything works fine. To do so, we create hello-world.js in our home directory file using the command below:

and add the following content into it and save the file:

Now we run the app with the following command

The output must be the one shown below

That means that node.js is installed correctly and working properly. You can now go ahead and create your incredible apps using node.js.

Testing With Node.JS Shell

Let’s start with the node command as follow and get its output result to see if Node.JS is fully functional.

REPL For Your NodeJS Apps

REPL is the Node.js shell, any valid Javascript which can be written in a script can be passed to the REPL. So let’s see how REPL works with NodeJS.

Here is the list of command line help that we can use to work with REPL.

Источник

Читайте также:  Командная строка windows запуск командных файлов
Оцените статью