Как скачать node js
Перейти к содержимому

Как скачать node js

  • автор:

Downloading and installing Node.js and npm

To publish and install packages to and from the public npm registry or a private npm registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager like nvm to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.

Note: to download the latest version of npm, on the command line, run the following command:

Checking your version of npm and Node.js

To see if you already have Node.js and npm installed and check the installed version, run the following commands:

Using a Node version manager to install Node.js and npm

Node version managers allow you to install and switch between multiple versions of Node.js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions.

OSX or Linux Node version managers

Windows Node version managers

Using a Node installer to install Node.js and npm

If you are unable to use a Node version manager, you can use a Node installer to install both Node.js and npm on your system.

If you use Linux, we recommend that you use a NodeSource installer.

OS X or Windows Node installers

If you're using OS X or Windows, use one of the installers from the Node.js download page. Be sure to install the version labeled LTS. Other versions have not yet been tested with npm.

Linux or other operating systems Node installers

If you're using Linux or another operating system, use one of the following installers:

    (recommended)
  • One of the installers on the Node.js download page

Or see this page to install npm for Linux in the way many Linux developers prefer.

# Installing Node.js

(opens new window) , otherwise known as nvm, is a bash script that simplifies the management of multiple Node.js versions.

To install nvm, use the provided install script:

For windows there is a nvm-windows package with an installer. This GithHub

(opens new window) page has the details for installing and using the nvm-windows package.

After installing nvm, run "nvm on" from command line. This enables nvm to control the node versions.

Note: You may need to restart your terminal for it to recognize the newly installed nvm command.

Then install the latest Node version:

You can also install a specific Node version, by passing the major, minor, and/or patch versions:

To list the versions available for install:

You can then switch versions by passing the version the same way you do when installing:

You can set a specific version of Node that you installed to be the default version by entering:

To display a list of Node versions that are installed on your machine, enter:

To use project-specific node versions, you can save the version in .nvmrc file. This way, starting to work with another project will be less error-prone after fetching it from its repository.

When Node is installed via nvm we don’t have to use sudo to install global packages since they are installed in home folder. Thus npm i -g http-server works without any permission errors.

# Installing Node.js on Mac using package manager

# Homebrew

You can install Node.js using the Homebrew

Start by updating brew:

You may need to change permissions or paths. It’s best to run this before proceeding:

Next you can install Node.js by running:

Once Node.js is installed, you can validate the version installed by running:

# Macports

You can also install node.js through Macports

First update it to make sure the lastest packages are referenced:

Then install nodejs and npm

You can now run node through CLI directly by invoking node . Also, you can check your current node version with

# Installing Node.js on Windows

Standard installation

All Node.js binaries, installers, and source files can be downloaded here

You can download just the node.exe runtime or use the Windows installer ( .msi ), which will also install npm , the recommended package manager for Node.js, and configure paths.

Installation by package manager

You can also install by package manager Chocolatey

(opens new window) (Software Management Automation).

More information about current version, you can find in the choco repository here

# Install Node.js on Ubuntu

# Using the apt package manager

# Using the latest of specific version (e.g. LTS 6.x) directly from nodesource

Also, for the right way to install global npm modules, set the personal directory for them (eliminates the need for sudo and avoids EACCES errors):

# Installing Node.js with n

First, there is a really nice wrapper for setting up n on your system. Just run:

to install n . Then install binaries in a variety of ways:

latest

stable

lts

Any other version

If this version is already installed, this command will activate that version.

Switching versions

n by itself will produce a selection list of installed binaries. Use up and down to find the one you want and Enter to activate it.

# Install Node.js From Source with APT package manager

Prerequisites

Get source and build

OR For the latest LTS Node.js version 6.10.2

Change to the source directory such as in cd

# Installing Node.js on Raspberry PI

To install v6.x update the packages

Using the apt package manager

# Installing with Node Version Manager under Fish Shell with Oh My Fish!

(opens new window) ( nvm ) greatly simplifies the management of Node.js versions, their installation, and removes the need for sudo when dealing with packages (e.g. npm install . ). Fish Shell

(opens new window) ( fish ) "is a smart and user-friendly command line shell for OS X, Linux, and the rest of the family" that is a popular alternative among programmers to common shells such as bash . Lastly, Oh My Fish

(opens new window) ( omf ) allows for customizing and installing packages within Fish shell.

This guide assumes you are already using Fish as your shell.

Install nvm

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

Install Oh My Fish

curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/bin/install | fish

(Note: You will be prompted to restart your terminal at this point. Go ahead and do so now.)

Install plugin-nvm for Oh My Fish

We will install plugin-nvm

(opens new window) via Oh My Fish to expose nvm capabilities within the Fish shell:

omf install nvm

Install Node.js with Node Version Manager

You are now ready to use nvm . You may install and use the version of Node.js of your liking. Some examples:

  • Install the most recent Node version: nvm install node
  • Install 6.3.1 specifically: nvm install 6.3.1
  • List installed verisons: nvm ls
  • Switch to a previously installed 4.3.1: nvm use 4.3.1

Final Notes

Remember again, that we no longer need sudo when dealing with Node.js using this method! Node versions, packages, and so on are installed in your home directory.

# Install Node.js from source on Centos, RHEL and Fedora

Prerequisites

  • git
  • clang and clang++ 3.4^ or gcc and g++ 4.8^
  • Python 2.6 or 2.7
  • GNU Make 3.81^

Get source

Node.js v6.x LTS

Node.js v7.x

Build

X — the number of processor cores, greatly speeds up the build

Cleanup [Optional]

# Installing using MacOS X Installer

You can find the installers on Node.js download page

(opens new window) . Normally, Node.js recommends two versions of Node, the LTS version (long term support) and the current version (latest release). If you are new to Node, just go for the LTS and then click the Macintosh Installer button to download the package.

If you want to find other NodeJS releases, go here

(opens new window) , choose your release then click download. From the download page, look for a file with extension .pkg .

Once you downloaded the file (with extension .pkg ofcourse), double click it to install. The installer packed with Node.js and npm , by default, the package will install both but you can customize which one to install by clicking the customize button in the Installation Type step. Other than that, just follow the installation instructions, it’s pretty straightforward.

# Check if Node is installed

Open terminal (if you don’t know how to open your terminal, look at this wikihow

(opens new window) ). In the terminal type node —version then enter. Your terminal will look like this if Node is installed:

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

Установка Node.js занимает всего несколько минут независимо от операционной системы. Сперва перейдите на официальный сайт платформы, где автоматически определяется тип и разрядность вашей операционной системы. На сайте предлагается установить Node.js либо самой последней (Current), либо стабильной версии (LTS).

Установка

Стабильная LTS версия в первую очередь предназначена для корпоративной разработки и в основном используется IT-компаниями, в которых частое обновление версий сопряжено с определенными трудностями в области закупок или согласно условия договоров со своими клиентами.

How to Install Node.js and NPM on Windows

Node.js is a run-time environment which includes everything you need to execute a program written in JavaScript. It’s used for running scripts on the server to render content before it is delivered to a web browser.

NPM stands for Node Package Manager, which is an application and repository for developing and sharing JavaScript code.

This guide will help you install and update Node.js and NPM on a Windows system and other useful Node.js commands.

Tutorial on how to install, use, update and remove Node.JS and NPM (Node package manager)

  • A user account with administrator privileges (or the ability to download and install software)
  • Access to the Windows command line (search > cmd > right-click > run as administrator) OR Windows PowerShell (Search > Powershell > right-click > run as administrator)

Note: If you want to install the run-time environment on a different operating systems, check out our guides on installing Node.js and NPM on CentOS 7, How to Install Node.js on Debian, or How to Install Node.js and NPM on Mac.

How to Install Node.js and NPM on Windows

Step 1: Download Node.js Installer

In a web browser, navigate to https://nodejs.org/en/download/. Click the Windows Installer button to download the latest default version. At the time this article was written, version 10.16.0-x64 was the latest version. The Node.js installer includes the NPM package manager.

Location of download link of NodeJS installer.

Note: There are other versions available. If you have an older system, you may need the 32-bit version. You can also use the top link to switch from the stable LTS version to the current version. If you are new to Node.js or don’t need a specific version, choose LTS.

Step 2: Install Node.js and NPM from Browser

1. Once the installer finishes downloading, launch it. Open the downloads link in your browser and click the file. Or, browse to the location where you have saved the file and double-click it to launch.

2. The system will ask if you want to run the software – click Run.

3. You will be welcomed to the Node.js Setup Wizard – click Next.

4. On the next screen, review the license agreement. Click Next if you agree to the terms and install the software.

5. The installer will prompt you for the installation location. Leave the default location, unless you have a specific need to install it somewhere else – then click Next.

6. The wizard will let you select components to include or remove from the installation. Again, unless you have a specific need, accept the defaults by clicking Next.

7. Finally, click the Install button to run the installer. When it finishes, click Finish.

Step 3: Verify Installation

Open a command prompt (or PowerShell), and enter the following:

The system should display the Node.js version installed on your system. You can do the same for NPM:

Testing Node JS and NPM on Windows using CMD

How to Update Node.js and NPM on Windows

The easiest way to update Node.js and NPM is to download the latest version of the software. On the Node.js download page, right below the Windows Installer link, it will display the latest version. You can compare this to the version you have installed.

To upgrade, download the installer and run it. The setup wizard will overwrite the old version, and replace it with the new version.

How to Uninstall Node.js and NPM on Windows

You can uninstall Node.js from the Control Panel in Windows.

  1. Click the Start button > Settings (gear icon) > Apps.
  2. Scroll down to find Node.js and click to highlight.
  3. Select Uninstall. This launches a wizard to uninstall the software.

Basic Node.js Usage

Node.js is a framework, which means that it doesn’t work as a normal application. Instead, it interprets commands that you write. To test your new Node.js installation, create a Hello World script.

1. Start by launching a text editor of your choice.

2. Next, copy and paste the following into the text editor you’ve just opened:

3. Save the file, then exit. Open the PowerShell, and enter the following:

It will look like nothing has happened. In reality, your script is running in the background. You may see a Windows Defender notice about allowing traffic – for now, click Allow.

4. Next, open a web browser, and enter the following into the address bar:

In the very upper-left corner, you should see the text Hello World!

Right now, your computer is acting like a server. Any other computer that tries to access your system on port 8080 will see the Hello World notice.

To turn off the program, switch back to PowerShell and press Ctrl+C. The system will switch back to a command prompt. You can close this window whenever you are ready.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *