Running node js 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:

Читайте также:  Windows 10 отменить группировку окон

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:

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:

Читайте также:  Как проверить язык windows

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.

Источник

Установка node.js на Linux, FreeBSD, Windows

Важное замечание.

В первую очередь хочу обратить внимание на то, что с развитием node.js его синтаксис менялся, порой несколько раз. В связи с этим, категорически не рекомендую использовать старые версии node, проскальзывающий недавно node.NET, и подобные сборки. Идеально — версия 0.1.90 или новее. По той же причине будьте внимательны при нахождениии в сети туториалов по установке. Те, что начинаются с wget http://s3.amazonaws… загрузят устаревшую версию.
Перед установкой убедитесь в том, что python установлен, он нужен для конфигурации и сборки с помощью make (актуально для всего, кроме Windows в некоторых случаях).

GNU/Linux

Лучше было бы собрать как минимум при помощи checkinstall
checkinstall —fstrans=no —install=no —pkgname=node.js —pkgversion «0.1.97» —default

Логика подсказывает, что под MacOS установка будет аналогичной, проверить не могу. Разработчики тестируют своё детище на MacOS, работать должно без проблем.

FreeBSD

На FreeBSD чтобы не собирать libexecinfo из портов достаточно сделать:
pkg_add -r libexecinfo

Итак, классический способ#1
Способ#2
Способ#3
Способ от AterCattus

При сборке под FreeBSD 8.0_RELEASE amd64 с первого раза не собралось:
. obj/release/cpu-profiler.o(.text._ZN2v88internal23ProfilerEventsProcessor19FunctionCreateEventEPhS2_i+0x81): In function `v8::internal::ProfilerEventsProcessor::FunctionCreateEvent(unsigned char*, unsigned char*, int)’:
: undefined reference to `v8::internal::OS::ReleaseStore(long volatile*, long)’
obj/release/cpu-profiler.o(.text._ZN2v88internal23ProfilerEventsProcessor15CodeCreateEventENS0_6Logger16LogEventsAndTagsEiPhj+0xa3): more undefined references to `v8::internal::OS::ReleaseStore(long volatile*, long)’ follow
scons: *** [obj/release/mksnapshot] Error 1
scons: building terminated because of errors.
Waf: Leaving directory `/home/atercattus/node.js/node-v0.1.97/build’
Build failed: -> task failed (err #2):
libv8.a>
*** Error code 1
Помогла эта ссылка: code.google.com/p/v8/issues/detail?id=726.
Там все просто, в v8/src/platform-freebsd.cc добавляется между int OS::ActivationFrameAlignment() и const char* OS::LocalTimezone(double time) реализация недостающей функции:
void OS::ReleaseStore(volatile AtomicWord* ptr, AtomicWord value) <
__asm__ __volatile__(«». «memory»);
*ptr = value;
>
Может кому поможет.

Обновление на момент 11 июня

Вышеприведённый патч не актуален для последней версии из git — само прекрасно компилится под freebsd-amd64

Источник

Установка Node.js в Ubuntu 20.04

Node Js — это платформа на основе JavaScript, которая уже завоевала большую популярность и становится еще более легкой и эффективной для разработчиков. Она позволяет программистам использовать JavaScript как для веб-приложений и пользовательских интерфейсов, так и для обычных программ, благодаря движку V8 от Google.

Для платформы уже создано более чем миллион пакетов, которыми можно управлять с помощью менеджера пакетов Node или NPM. Это отличная система для расширяемости приложения с помощью решений с открытым исходным кодом. В этой статье мы рассмотрим четыре способа установить Node.js в Ubuntu 20.04. Мы рассмотрим их все ниже, но рекомендуется использовать первый:

  • Использовать скрипт NVM, для управления несколькими версиями Node.js;
  • Установить программу из официальных репозиториев вашего дистрибутива;
  • Установить пакеты из PPA;
  • Установка Node.js из бинарных пакетов, распространяемых на официальном сайте;

Первый способ рекомендованный, но второй более простой, третий и четвертый позволяют получить более новые версии программ. Если у вас уже была установлена более старая версия Node js, ее нужно удалить, чтобы не возникало конфликтов, также вы можете просто обновить программу, для этого смотрите статью как обновить Node.js на Windows, Linux и Mac.

Удалить старую версию Node.js

В Ubuntu пакет Node Js называется по-старому — Node, эта программа вам не нужна и вы можете ее удалить. Если программа останется, некоторые операции могут выполняться с помощью нее и это будет вызывать конфликты.

Сначала давайте проверим установлена ли у вас эта программа:

dpkg —get-selections | grep node

Теперь вы можете ее удалить с помощью следующих команд:

sudo apt purge nodejs

Теперь можно переходить к рассмотрению того как установить Node.js в Ubuntu 20.04.

Установка Node.js в Node Version Manager

Чтобы установить Node.js Ubuntu 20.04 с помощью NVM нам понадобится компилятор C++ в системе, а также другие инструменты для сборки. По умолчанию система не поставляется с этими программами, поэтому их необходимо установить. Для этого выполните команду:

sudo apt install build-essential checkinstall

Также нам понадобится libssl:

sudo apt install libssl-dev

Скачать и установить менеджер версий NVM можно с помощью следующей команды:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

После завершения установки вам понадобится перезапустить терминал. Или можно выполнить:

Затем смотрим список доступных версий Node js:

Дальше можно устанавливать Node js в Ubuntu, при установке обязательно указывать версию, на данный момент самая последняя 11.0, но установим десятую:

nvm install 14.0

Список установленных версий вы можете посмотреть выполнив:

Дальше необходимо указать менеджеру какую версию нужно использовать:

Как только появятся более новые версии node js, вы сможете их установить и активировать в системе. Посмотреть версию вы можете выполнив команду:

Чтобы удалить эту версию node js, ее нужно деактивировать:

nvm deactivate 14.0

Затем можно удалить:

nvm uninstall 14.0

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

Это самый простой способ установки этой платформы. Сначала выполните команду:

sudo apt install nodejs

Затем установите менеджер пакетов npm:

sudo apt install npm

Теперь вы можете проверить работоспособность только что установленных программ:

Как видите, при использовании официальных репозиториев вы получаете более старую версию.

Установка Node js из PPA

Установка Node js Ubuntu из PPA, это альтернативный вариант, позволяющий получить более новую версию, достаточно простым способом. Сначала добавьте репозитории Node js в список репозиториев Ubuntu с помощью такой одной из следующих команд. Для установки самой последней версии выполните:

curl -sL https://deb.nodesource.com/setup_15.x | sudo bash —

А для стабильной:

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

Затем просто установите программу с помощью пакетного менеджера:

sudo apt install nodejs

Проверяем, что получилось:

Установка Node js из бинарников

Установка Node.js Ubuntu 20.04 через бинарные файлы не рекомендуется, потому что вы не сможете автоматически обновить программу до новой версии, вам придется повторять процедуру заново. Вы можете скачать установочные файлы Node js из официального сайта проекта. Здесь доступны как 32 битная, так и 64 битная версия. Вам нужно скачать файл именно для своей системы.

Чтобы узнать архитектуру выполните:

Откройте официальный сайт Node.js и найдите нужную версию, затем скачайте архив для своей архитектуры:

Вы можете скачать Node js и с помощью терминала, например, эта команда для 64 бит версии:

Теперь распаковываем бинарные файлы программы:

sudo tar -C /usr/local —strip-components 1 -xf ./node-v15.0.0-linux-x64.tar.gz

Смотрим версию, чтобы убедится, что все работает:

Источник

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