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

Введение

Node или Node.js — программная платформа, основанная на движке V8 (транслирующем JavaScript в машинный код), превращающая JavaScript из узкоспециализированного языка в язык общего назначения.

Node.js добавляет возможность JavaScript взаимодействовать с устройствами ввода-вывода через свой API , написанный на C++ , подключать другие внешние библиотеки, написанные на разных языках, обеспечивая вызовы к ним из JavaScript-кода.

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

Также есть возможность разрабатывать на Node.js и десктопные оконные приложения (при помощи NW.js, AppJS или Electron для Linux , Windows и macOS) и даже программировать микроконтроллеры (например, tessel, low.js и espruino).

В основе Node.js лежит событийно-ориентированное и асинхронное (или реактивное) программирование с неблокирующим вводом/выводом.

Установка в Windows

Скачайте Node.js с официального сайта nodejs.org

Выбираем версию LTS (Recommended for most users)

Должен загрузиться файл .msi, например node-v22.14.0-x64.msi

Устанавливаем и затем проверяем версию командой

$ node -v

v22.14.0

Нажмите Run Software

 изображение с сайта www.testsetup.ru
Установка PyTest
https://testsetup.ru

Дождитесь установки

 изображение с сайта www.testsetup.ru
Установка PyTest
https://testsetup.ru

Желательно перезагрузиться

 изображение с сайта www.testsetup.ru
Установка PyTest
https://testsetup.ru

Источник: testsetup.ru

 изображение с сайта www.testsetup.ru
Установка PyTest
https://testsetup.ru

Источник: testsetup.ru

 изображение с сайта www.testsetup.ru
Установка PyTest
https://testsetup.ru

Источник: testsetup.ru

 изображение с сайта www.testsetup.ru
Установка PyTest
https://testsetup.ru

Источник: testsetup.ru

 изображение с сайта www.testsetup.ru
Установка PyTest
https://testsetup.ru

Источник: testsetup.ru

 изображение с сайта www.testsetup.ru
Установка PyTest
https://testsetup.ru

PowerShell скрипт

Пример скачивания и установки node-v24.15.0-x64 с помощью PowerShell скрипта.

# Node.js download URL $nodeUrl = "https://nodejs.org/dist/v24.15.0/node-v24.15.0-x64.msi" # Save installer to the current directory $installerPath = Join-Path (Get-Location) "node-v24.15.0-x64.msi" function node_is_in_path { Write-Host "Verifying installation using PATH (node -v, npm -v)..." -ForegroundColor Cyan try { node -v npm -v Write-Host "Primary verification succeeded." -ForegroundColor Green return $true } catch { Write-Host "WARNING: Primary verification failed. PATH may not be updated yet." -ForegroundColor Yellow return $false } } function node_exe_works { try { Write-Host "Trying full-path verification: & 'C:\Program Files\nodejs\node.exe' -v" -ForegroundColor Cyan & "C:\Program Files\nodejs\node.exe" -v Write-Host "Full-path verification succeeded." -ForegroundColor Green return $true } catch { Write-Host "WARNING: Full-path verification failed." -ForegroundColor Yellow return $false } } function nodejs_dir_exists { try { Write-Host "Checking if C:\Program Files\nodejs exists..." -ForegroundColor Cyan Get-ChildItem "C:\Program Files\nodejs" | Out-Null Write-Host "Node.js directory found." -ForegroundColor Cyan return $true } catch { Write-Host "WARNING: Node.js directory not found. Installation may have failed." -ForegroundColor Red Write-Host "Verify that you are running PowerShell as Administrator." -ForegroundColor Yellow exit 1 } } function reload_path { Write-Host "Reloading PATH environment variable..." -ForegroundColor Cyan $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") Write-Host "PATH successfully reloaded for this session." -ForegroundColor Green } # ----------------------------- # Step 1: Check if file exists # ----------------------------- if (Test-Path $installerPath) { Write-Host "Installer already exists: $installerPath" -ForegroundColor Yellow Write-Host "Skipping download step." } else { try { Write-Host "Downloading Node.js installer..." -ForegroundColor Cyan Invoke-WebRequest -Uri $nodeUrl -OutFile $installerPath -ErrorAction Stop Write-Host "Download completed: $installerPath" -ForegroundColor Green } catch { Write-Host "ERROR: Failed to download Node.js installer." -ForegroundColor Red Write-Host $_.Exception.Message -ForegroundColor DarkRed exit 1 } } # ----------------------------- # Step 2: Silent installation # ----------------------------- try { Write-Host "Installing Node.js silently..." -ForegroundColor Cyan Start-Process "msiexec.exe" ` -ArgumentList "/i `"$installerPath`" /qn /norestart" ` -Wait -ErrorAction Stop Write-Host "Node.js installation completed." -ForegroundColor Green } catch { Write-Host "ERROR: Node.js installation failed." -ForegroundColor Red Write-Host $_.Exception.Message -ForegroundColor DarkRed exit 1 } # ----------------------------- # Step 3: Primary verification (PATH) # ----------------------------- $node_installed_and_in_path = node_is_in_path if ($node_installed_and_in_path) { Write-Host "Installation verified successfully. No further checks needed." -ForegroundColor Green exit 0 } # ----------------------------- # Step 4: Fallback verification (full path) # ----------------------------- $node_installed = node_exe_works if ($node_installed) { reload_path } else { Write-Host "Since Full-path verification failed we are trying final fallback" -ForegroundColor Yellow $node_dir_exists = nodejs_dir_exists if ($node_dir_exists) { Write-Host "C:\Program Files\nodejs\ dir exists" -ForegroundColor Cyan } else { Write-Host "ERROR: C:\Program Files\nodejs\ dir does not exist. Probably installation failed or used unknown dir" -ForegroundColor Red } exit 1 } # ----------------------------- # Step 5: Verifies that Path update helped # ----------------------------- $node_installed_and_in_path = node_is_in_path if ($node_installed_and_in_path) { Write-Host "Installation verified successfully after path was updated. No further checks needed." -ForegroundColor Green exit 0 } else { Write-Host "ERROR: node is available by C:\Program Files\nodejs\node.exe but PATH update did not help" -ForegroundColor Red exit 1 }

Установка в Linux

В Ubuntu Debian и т.д.

sudo apt install nodejs

В CentOS , Rocky , Red Hat, Fedora и т.д.

sudo yum install nodejs

Устанавливаем и затем проверяем версию командой

$ node -v

v10.21.0

Установка последней версии Node.js

В репозитории по умолчанию может быть довольно старая версия Node.js. Это зависит от дистрибутива Linux.

В Fedora, скорее всего будет новая версия.

А в стабильной Ubuntu старая и, например, для работы RFBrowser она не подходит.

Установить нужную версию можно следующим способом

sudo apt -y install curl gcc g++ make
curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt -y install nodejs
node -v

v16.14.0

Если вам нужна не 16-я версия - просто заменить setup_16.x на нужную

Во время установки будет примерно такой лог

## Installing the NodeSource Node.js 16.x repo... ## Populating apt-get cache... + apt-get update Hit:1 http://fi.archive.ubuntu.com/ubuntu jammy InRelease Get:2 http://fi.archive.ubuntu.com/ubuntu jammy-updates InRelease [109 kB] Get:3 http://fi.archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB] Get:4 http://fi.archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB] Get:5 http://fi.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [221 kB] Get:6 http://fi.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [102 kB] Fetched 644 kB in 0s (1,614 kB/s) Reading package lists... Done ## Confirming "jammy" is supported... + curl -sLf -o /dev/null 'https://deb.nodesource.com/node_16.x/dists/jammy/Release' ## Adding the NodeSource signing key to your keyring... + curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null ## Creating apt sources list file for the NodeSource Node.js 16.x repo... + echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x jammy main' > /etc/apt/sources.list.d/nodesource.list + echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x jammy main' >> /etc/apt/sources.list.d/nodesource.list ## Running `apt-get update` for you... + apt-get update Hit:1 http://fi.archive.ubuntu.com/ubuntu jammy InRelease Hit:2 http://fi.archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:3 http://fi.archive.ubuntu.com/ubuntu jammy-backports InRelease Hit:4 http://fi.archive.ubuntu.com/ubuntu jammy-security InRelease Get:5 https://deb.nodesource.com/node_16.x jammy InRelease [4,583 B] Get:6 https://deb.nodesource.com/node_16.x jammy/main amd64 Packages [774 B] Fetched 5,357 B in 0s (13.5 kB/s) Reading package lists... Done ## Run `sudo apt-get install -y nodejs` to install Node.js 16.x and npm ## You may also need development tools to build native addons: sudo apt-get install gcc g++ make ## To install the Yarn package manager, run: curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn

Автор статьи: Андрей Олегович