Как обновить node js через консоль linux

Содержание
  1. How to Update Node.js to Latest Version Home » DevOps and Development » How to Update Node.js to Latest Version Node.js is an open-source JavaScript runtime environment. Since Node.js has an active community of users, minor updates of the software come out every few weeks. You may be using Node.js as a layer of the MEAN stack or in a different JS framework. Either way, make sure to update Node.js regularly to ensure system security. There are several ways to install Node.js and NPM. Likewise, there are several ways to update your Node.js version, depending on the operating system running on your machine. In this article, you will learn how to update to the latest Node.js version on Linux, Windows, and macOS. 3 Ways to Update Node.js to Latest Version on Linux Systems There are different ways to update Node.js if you are using a Linux-based system. Although using the Node Version Manager is the easiest and most recommended option, you can also update with the local package manager or by downloading the binary packages. Option 1: Update Node.js with NVM (Node Version Manager) The best way to upgrade Node.js is with NVM, a practical tool for managing multiple Node.js versions. 1. Start by updating the package repository with the command: 2. Install NVM using the curl command: Note: If you don’t have curl , install the utility by running the command: sudo apt install curl . Alternatively, you use wget and run the command: 3. Close and reopen the terminal for system to recognize the changes or run the command: 5. Then, verify if you have successfully installed NVM: 6. Before upgrading Node.js, check which version you have running on the system: 7. Now you can check for newly available releases with: 8. To install the latest version, use the nvm command with the specific Node.js version: Option 2: Update Node.js with NPM (Node Package Manager) As an alternative, you can use Node’s official package manager to update Node.js. NPM is a tool for installing and managing package dependencies. If you have Node on your system, you have NPM, as well. With the npm command, you can check running Node.js versions and install the latest release. By adding the n module, you can interactively manage Node.js versions. 1. First, clear the npm cache: 2. Install n, Node’s version manager: 3. With the n module installed, you can use it to: Install the latest stable version: Note: Some Ubuntu distros may respond with the command not found output after running the n command. To fix this issue run sudo -E env «PATH=$PATH» [command] . For example, to install the latest stable version, as in the example above, you would run sudo -E env «PATH=$PATH» n stable . Install the latest release: Install a specific version: Option 3: Update Node.js with Binary Packages Updating Node.js with binary packages is the least recommended option. However, if it is the only way you can upgrade to the latest Node.js version, follow the steps outlined below. 1. Navigate to Node’s official downloads page where you can find all available packages. There you can download the source code or pre-built installer for the LTS versions or the latest release. 2. You can either download the package from your browser or find the version number you need and add it to the wget command: 3. Next, install xz-utils used to extract the binary package: 4. Extract and install the package with the command: Update Node.js to Latest Version on Windows and macOS Updating Node.js on Windows and macOS follows the same principles. There are two simple ways to upgrade: Download the latest Node.js release from its official download page and install the new Node.js release. Install the n module and update Node.js inside the terminal window. Option 1: Update Node.js on Windows and macOS with Installer One way to update your Node.js is to go to its official download page and install the newest release. Bz doing so, the system should overwrite the older version with the updated one. 1. Navigate to the Node.js website and click on the latest stable version or the newest current release (with the latest features). 2. After deciding the version, click on the Windows or the macOS Installer, depending on the system you are using. The system downloads the package and stores it in the specified directory. 3. Once the download is complete, run the installer. 4. The Node.js Setup Wizard appears and guides you through the installation. 5. Accept the License Agreement by checking the box and click Next. 6. Choose the destination folder where you want to install Node.js. 7. Node.js allows you to select how you want to install the Node features. Change the way the features are installed by clicking on the icons in the tree. 8. With that, the latest Node.js is ready to install. Click Install to confirm, wait until the installation completes, and click Finish. 9. Check the Node.js version with the command: Note: Sometimes, the system fails to overwrite the older Node.js release and you may end up with two versions. If such problems occur, you may want to consider updating with NPM, outlined in the section below. Option 2: Update Node.js on Windows and macOS with NPM If you want to upgrade Node.js from the command line, use the n model within the npm command. The n feature allows you to interact with different Node.js versions. 1. Before updating the Node.js release, check which version you are currently using with: 2. Next, clear npm cache with the command: 3. Install n globally: 4. Now that you have n installed, you can use the module to install the latest stable release of Node.js: Alternatively, you can install the Node.js release with the latest features: Or, install a specific version number with: The best part of open-source technology is its strong community of users constantly working on upgrading the software. Источник Как мне обновить Node.js? Я сделал следующее, чтобы обновить свой npm: Но я понятия не имею, как обновить Node.js. Какие-либо предложения? (Я использую Node.js 0.4.1 и хочу обновить его до Node.js 0.6.1.) 28 ответов Это сценарий Bash, который позволяет загружать разные версии node. Полный исходный код находится здесь. Для nvm для Windows существует отдельный проект: github.com/coreybutler/nvm-windows Ниже приведены полные инструкции по использованию NVM для нескольких версий узла в Windows. загрузите извлечение nvm-setup.zip и установите его. выполните команду nvm list available из cmd, gitbash или powershell, это отобразит все доступные версии узла используйте команду nvm install version например nvm install 12.14.0 для установки на машину последний раз после установки используйте nvm use version , чтобы использовать более новую версию, например nvm use 12.14.0 Согласно официальной странице Nodejs, вы можете установить и обновить новую версию узла в Windows, используя Шоколадный или Scoop Использование (шоколадного): Использование (Совок): Также вы можете загрузить установщик Windows прямо с веб-сайта nodejs.org. Установить nvm (cURL) Показать список установленных версий Показать список версий, доступных для установки Установите желаемую версию $ nvm установить v7.5.0 Установить эту версию по умолчанию $ nvm псевдоним по умолчанию v7.5.0 Работал у меня, чтобы обновить npm Вы можете использовать Chocolatey в Windows. Он очень прост в использовании и полезен для того, чтобы держать вас в курсе и других приложений. Кроме того, вы можете просто загрузить последнюю версию с https://nodejs.org и установить ее. Откройте cmd и введите Если вы хотите обновить Node.js, просто попробуйте Из командной строки Windows. В противном случае, если вы хотите обновить какой-либо конкретный пакет, попробуйте npm clean cache — вы забыли очистить кеш Это работает на моей Windows, надеюсь, это сработает и для вас: D В Windows загрузите исполняемый файл узла с веб-сайта и установите его. это сработало для меня. Просто установите новую версию поверх текущей папки. Я обновил свой с v4.x до v6.10 в Windows. Все, что вам нужно для обновления версии Node.js: Если у вас нет Homebrew; перейдите по ссылке http://brew.sh/. Как некоторые из вас уже сказали, самый простой способ — обновить Node.js с помощью диспетчера пакетов Node.js, npm. Если вы являетесь пользователем Linux (Debian в моем случае), я бы предложил добавить эти строки в ваш файл .bashrc (в домашнем каталоге): После сохранения перезагрузите терминал и напишите nodejsupdate для обновления до последней версии Node.js или nodejsupdate v6.0.0 (например) для обновления до определенной версии Node.js. БОНУС: обновите npm (добавьте эти строки в .bashrc ) После перезапуска терминала напишите npmupdate , чтобы обновить диспетчер пакетов узла до последней версии. Теперь вы можете обновлять Node.js и npm через терминал (проще). Сегодня я запустил Windows Git Bash: И получил следующий результат: Дополнительные сведения об этом см. На странице https://www.npmjs.com/package/node. Простой способ обновить node и npm: Загрузите последнюю версию node js и обновите / установите Для macOS 2018+ (поскольку ВСЕ вышеперечисленные решения не работают для меня): Просто перейдите на официальный сайт nodejs, загрузите официальный пакет nodejs и установите его двойным щелчком. Это самое простое, безопасное и всегда работающее действие, которое вы можете сделать. В репозиториях пакетов некоторых дистрибутивов Linux, таких как Arch Linux, есть Node.js. В таких системах лучше использовать стандартную процедуру обновления пакета, такую ​​как pacman -Suy или аналогичные команды apt-get или yum . На данный момент (ноябрь 2016 г.) EPEL7 предлагает довольно свежую версию Node.js (6.9.1, последняя версия LTS, предлагаемая на домашней странице Node.js). Таким образом, в CentOS 7 и производных вы можете просто добавить репозиторий EPEL с помощью yum install epel-release и yum install nodejs . CentOS 6 / EPEL6 имеет версию 0.10.x, которая не поддерживается в восходящем направлении с октября 2016 года. Вы можете использовать nvm. Проверьте последнюю версию на http://nodejs.org/ (например, v0.10.26). Запустите nvm install v0.10.26 Вы можете выбрать, какую версию запускать: nvm ls перечисляет доступные версии и сообщает, какую версию вы используете сейчас. nvm use VERSION изменить текущий узел на запрошенную версию. nvm alias default VERSION устанавливает версию по умолчанию. В следующий раз, когда вы создадите nvm.sh, эта версия будет загружена (обратите внимание, что она не меняет используемую версию прямо сейчас, для этого запустите nvm use ). Для OS X у меня была v5.4.1, и мне нужна была последняя версия 6, поэтому я перешел на домашнюю страницу Node.js. и щелкнул по одной из ссылок ниже: Затем я последовал за установщиком, и у меня волшебным образом появилась последняя версия Node.js и npm. В CentOS 7 вы можете делать следующее: Примечание. Символьная ссылка требуется для связывания двоичного файла вашего узла с последним установленным двоичным файлом Node.js. У меня была такая же проблема, когда я увидел, что моя установка Node.js устарела. Эти несколько строк будут обрабатывать все (для Ubuntu) : После этого node -v вернет вам последнюю доступную версию. Короткий и глупый ответ: Перейдите на эту страницу: Загрузить | Node.js Загрузите установщик для своей платформы, затем установите его. Чтобы управлять своей версией Node.js, вы можете попробовать n . Я нашел это очень простым и полезным. n — это двоичное управление Node.js, без подоболочек, без настройки профиля, без запутанного API, просто. n 0.6.19 установит Node.js v0.6.19. Чтобы обновить узел до последней версии или до конкретной версии, вы можете сделать следующее: Для последней стабильной версии: Для последней версии LTS (проверено на Mac) В Windows вы можете использовать Chocolatey для установки и обновления Node.js (и множества других пакетов ). Установить узел Обновить узел Примечание: вам необходимо установить Chocolatey, прежде чем вы сможете использовать cinst и cup . Первое обновление npm , npm install -g npm stable Затем обновите node , npm install -g node или npm install -g n Проверьте после установки версии, node —version или node -v Если у вас установлен Homebrew (только для macOS): Я использовал следующие инструкции для обновления с Node.js версии 0.10.6 до 0.10.21 на Mac. Очистить кэш NPM: Установите последнюю стабильную версию Node.js В качестве альтернативы выберите конкретную версию и установите ее следующим образом: В производственных средах вы можете обратить внимание на нумерацию версий и быть разборчивыми в отношении четных и нечетных чисел. Общая процедура: Д.Уолш Стабильный / нестабильные версии: P.Teixeira Обновление (июнь 2017 г.): Этот пост четырехлетней давности все еще получает голоса, так что я предполагаю, что он все еще работает для многих людей. Однако сам г-н Уолш рекомендовал вместо этого обновлять Node.js, просто используя nvm. Итак, вот что вы, возможно, захотите сделать сегодня: Узнайте, какую версию Node.js вы используете: Узнайте, какие версии Node.js вы могли установить и какую из них используете в настоящее время: Перечислите все версии Node.js, доступные для установки: Очевидно для Windows команда будет выглядеть примерно так: Источник
  2. 3 Ways to Update Node.js to Latest Version on Linux Systems
  3. Option 1: Update Node.js with NVM (Node Version Manager)
  4. Option 2: Update Node.js with NPM (Node Package Manager)
  5. Option 3: Update Node.js with Binary Packages
  6. Update Node.js to Latest Version on Windows and macOS
  7. Option 1: Update Node.js on Windows and macOS with Installer
  8. Option 2: Update Node.js on Windows and macOS with NPM
  9. Как мне обновить Node.js?
  10. 28 ответов
Читайте также:  Jetbrains webstorm linux install

How to Update Node.js to Latest Version

Home » DevOps and Development » How to Update Node.js to Latest Version

Node.js is an open-source JavaScript runtime environment. Since Node.js has an active community of users, minor updates of the software come out every few weeks.

You may be using Node.js as a layer of the MEAN stack or in a different JS framework. Either way, make sure to update Node.js regularly to ensure system security.

There are several ways to install Node.js and NPM. Likewise, there are several ways to update your Node.js version, depending on the operating system running on your machine.

In this article, you will learn how to update to the latest Node.js version on Linux, Windows, and macOS.

3 Ways to Update Node.js to Latest Version on Linux Systems

There are different ways to update Node.js if you are using a Linux-based system. Although using the Node Version Manager is the easiest and most recommended option, you can also update with the local package manager or by downloading the binary packages.

Option 1: Update Node.js with NVM (Node Version Manager)

The best way to upgrade Node.js is with NVM, a practical tool for managing multiple Node.js versions.

1. Start by updating the package repository with the command:

2. Install NVM using the curl command:

Note: If you don’t have curl , install the utility by running the command: sudo apt install curl .

Alternatively, you use wget and run the command:

3. Close and reopen the terminal for system to recognize the changes or run the command:

5. Then, verify if you have successfully installed NVM:

6. Before upgrading Node.js, check which version you have running on the system:

7. Now you can check for newly available releases with:

8. To install the latest version, use the nvm command with the specific Node.js version:

Option 2: Update Node.js with NPM (Node Package Manager)

As an alternative, you can use Node’s official package manager to update Node.js. NPM is a tool for installing and managing package dependencies.

If you have Node on your system, you have NPM, as well. With the npm command, you can check running Node.js versions and install the latest release.

By adding the n module, you can interactively manage Node.js versions.

1. First, clear the npm cache:

2. Install n, Node’s version manager:

3. With the n module installed, you can use it to:

Install the latest stable version:

Note: Some Ubuntu distros may respond with the command not found output after running the n command. To fix this issue run sudo -E env «PATH=$PATH» [command] . For example, to install the latest stable version, as in the example above, you would run sudo -E env «PATH=$PATH» n stable .

Install the latest release:

Install a specific version:

Option 3: Update Node.js with Binary Packages

Updating Node.js with binary packages is the least recommended option. However, if it is the only way you can upgrade to the latest Node.js version, follow the steps outlined below.

1. Navigate to Node’s official downloads page where you can find all available packages. There you can download the source code or pre-built installer for the LTS versions or the latest release.

2. You can either download the package from your browser or find the version number you need and add it to the wget command:

3. Next, install xz-utils used to extract the binary package:

4. Extract and install the package with the command:

Update Node.js to Latest Version on Windows and macOS

Updating Node.js on Windows and macOS follows the same principles.

There are two simple ways to upgrade:

  • Download the latest Node.js release from its official download page and install the new Node.js release.
  • Install the n module and update Node.js inside the terminal window.

Option 1: Update Node.js on Windows and macOS with Installer

One way to update your Node.js is to go to its official download page and install the newest release. Bz doing so, the system should overwrite the older version with the updated one.

1. Navigate to the Node.js website and click on the latest stable version or the newest current release (with the latest features).

2. After deciding the version, click on the Windows or the macOS Installer, depending on the system you are using. The system downloads the package and stores it in the specified directory.

3. Once the download is complete, run the installer.

4. The Node.js Setup Wizard appears and guides you through the installation.

5. Accept the License Agreement by checking the box and click Next.

6. Choose the destination folder where you want to install Node.js.

7. Node.js allows you to select how you want to install the Node features. Change the way the features are installed by clicking on the icons in the tree.

8. With that, the latest Node.js is ready to install. Click Install to confirm, wait until the installation completes, and click Finish.

9. Check the Node.js version with the command:

Note: Sometimes, the system fails to overwrite the older Node.js release and you may end up with two versions. If such problems occur, you may want to consider updating with NPM, outlined in the section below.

Option 2: Update Node.js on Windows and macOS with NPM

If you want to upgrade Node.js from the command line, use the n model within the npm command. The n feature allows you to interact with different Node.js versions.

1. Before updating the Node.js release, check which version you are currently using with:

2. Next, clear npm cache with the command:

3. Install n globally:

4. Now that you have n installed, you can use the module to install the latest stable release of Node.js:

Alternatively, you can install the Node.js release with the latest features:

Or, install a specific version number with:

The best part of open-source technology is its strong community of users constantly working on upgrading the software.

Источник

Как мне обновить Node.js?

Я сделал следующее, чтобы обновить свой npm:

Но я понятия не имею, как обновить Node.js. Какие-либо предложения? (Я использую Node.js 0.4.1 и хочу обновить его до Node.js 0.6.1.)

28 ответов

Это сценарий Bash, который позволяет загружать разные версии node. Полный исходный код находится здесь.

Для nvm для Windows существует отдельный проект: github.com/coreybutler/nvm-windows

Ниже приведены полные инструкции по использованию NVM для нескольких версий узла в Windows.

  1. загрузите извлечение nvm-setup.zip и установите его.
  2. выполните команду nvm list available из cmd, gitbash или powershell, это отобразит все доступные версии узла
  3. используйте команду nvm install version например nvm install 12.14.0 для установки на машину
  4. последний раз после установки используйте nvm use version , чтобы использовать более новую версию, например nvm use 12.14.0

Согласно официальной странице Nodejs, вы можете установить и обновить новую версию узла в Windows, используя Шоколадный или Scoop

Использование (шоколадного):

Использование (Совок):

Также вы можете загрузить установщик Windows прямо с веб-сайта nodejs.org.

Установить nvm (cURL)

Показать список установленных версий

Показать список версий, доступных для установки

Установите желаемую версию

$ nvm установить v7.5.0

Установить эту версию по умолчанию

$ nvm псевдоним по умолчанию v7.5.0

Работал у меня, чтобы обновить npm

Вы можете использовать Chocolatey в Windows. Он очень прост в использовании и полезен для того, чтобы держать вас в курсе и других приложений.

Кроме того, вы можете просто загрузить последнюю версию с https://nodejs.org и установить ее.

Откройте cmd и введите

Если вы хотите обновить Node.js, просто попробуйте

Из командной строки Windows.

В противном случае, если вы хотите обновить какой-либо конкретный пакет, попробуйте

npm clean cache — вы забыли очистить кеш

Это работает на моей Windows, надеюсь, это сработает и для вас: D

В Windows загрузите исполняемый файл узла с веб-сайта и установите его. это сработало для меня.

Просто установите новую версию поверх текущей папки. Я обновил свой с v4.x до v6.10 в Windows.

Все, что вам нужно для обновления версии Node.js:

Если у вас нет Homebrew; перейдите по ссылке http://brew.sh/.

Как некоторые из вас уже сказали, самый простой способ — обновить Node.js с помощью диспетчера пакетов Node.js, npm. Если вы являетесь пользователем Linux (Debian в моем случае), я бы предложил добавить эти строки в ваш файл .bashrc (в домашнем каталоге):

После сохранения перезагрузите терминал и напишите nodejsupdate для обновления до последней версии Node.js или nodejsupdate v6.0.0 (например) для обновления до определенной версии Node.js.

БОНУС: обновите npm (добавьте эти строки в .bashrc )

После перезапуска терминала напишите npmupdate , чтобы обновить диспетчер пакетов узла до последней версии.

Теперь вы можете обновлять Node.js и npm через терминал (проще).

Сегодня я запустил Windows Git Bash:

И получил следующий результат:

Дополнительные сведения об этом см. На странице https://www.npmjs.com/package/node.

Простой способ обновить node и npm:

Загрузите последнюю версию node js и обновите / установите

Для macOS 2018+ (поскольку ВСЕ вышеперечисленные решения не работают для меня):

Просто перейдите на официальный сайт nodejs, загрузите официальный пакет nodejs и установите его двойным щелчком. Это самое простое, безопасное и всегда работающее действие, которое вы можете сделать.

В репозиториях пакетов некоторых дистрибутивов Linux, таких как Arch Linux, есть Node.js. В таких системах лучше использовать стандартную процедуру обновления пакета, такую ​​как pacman -Suy или аналогичные команды apt-get или yum .

На данный момент (ноябрь 2016 г.) EPEL7 предлагает довольно свежую версию Node.js (6.9.1, последняя версия LTS, предлагаемая на домашней странице Node.js). Таким образом, в CentOS 7 и производных вы можете просто добавить репозиторий EPEL с помощью yum install epel-release и yum install nodejs .

CentOS 6 / EPEL6 имеет версию 0.10.x, которая не поддерживается в восходящем направлении с октября 2016 года.

Вы можете использовать nvm.

  1. Проверьте последнюю версию на http://nodejs.org/ (например, v0.10.26).
  2. Запустите nvm install v0.10.26

Вы можете выбрать, какую версию запускать:

nvm ls перечисляет доступные версии и сообщает, какую версию вы используете сейчас.

nvm use VERSION изменить текущий узел на запрошенную версию.

nvm alias default VERSION устанавливает версию по умолчанию. В следующий раз, когда вы создадите nvm.sh, эта версия будет загружена (обратите внимание, что она не меняет используемую версию прямо сейчас, для этого запустите nvm use ).

Для OS X у меня была v5.4.1, и мне нужна была последняя версия 6, поэтому я перешел на домашнюю страницу Node.js. и щелкнул по одной из ссылок ниже:

Затем я последовал за установщиком, и у меня волшебным образом появилась последняя версия Node.js и npm.

В CentOS 7 вы можете делать следующее:

Примечание. Символьная ссылка требуется для связывания двоичного файла вашего узла с последним установленным двоичным файлом Node.js.

У меня была такая же проблема, когда я увидел, что моя установка Node.js устарела.

Эти несколько строк будут обрабатывать все (для Ubuntu ) :

После этого node -v вернет вам последнюю доступную версию.

Короткий и глупый ответ:

Перейдите на эту страницу: Загрузить | Node.js

Загрузите установщик для своей платформы, затем установите его.

Чтобы управлять своей версией Node.js, вы можете попробовать n . Я нашел это очень простым и полезным.

n — это двоичное управление Node.js, без подоболочек, без настройки профиля, без запутанного API, просто.

n 0.6.19 установит Node.js v0.6.19.

Чтобы обновить узел до последней версии или до конкретной версии, вы можете сделать следующее:

Для последней стабильной версии:

Для последней версии LTS (проверено на Mac)

В Windows вы можете использовать Chocolatey для установки и обновления Node.js (и множества других пакетов ).

Установить узел

Обновить узел

Примечание: вам необходимо установить Chocolatey, прежде чем вы сможете использовать cinst и cup .

Первое обновление npm ,

npm install -g npm stable

Затем обновите node ,

npm install -g node или npm install -g n

Проверьте после установки версии,

node —version или node -v

Если у вас установлен Homebrew (только для macOS):

Я использовал следующие инструкции для обновления с Node.js версии 0.10.6 до 0.10.21 на Mac.

Очистить кэш NPM:

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

В качестве альтернативы выберите конкретную версию и установите ее следующим образом:

В производственных средах вы можете обратить внимание на нумерацию версий и быть разборчивыми в отношении четных и нечетных чисел.

  • Общая процедура: Д.Уолш
  • Стабильный / нестабильные версии: P.Teixeira

Обновление (июнь 2017 г.):

Этот пост четырехлетней давности все еще получает голоса, так что я предполагаю, что он все еще работает для многих людей. Однако сам г-н Уолш рекомендовал вместо этого обновлять Node.js, просто используя nvm.

Итак, вот что вы, возможно, захотите сделать сегодня:

Узнайте, какую версию Node.js вы используете:

Узнайте, какие версии Node.js вы могли установить и какую из них используете в настоящее время:

Перечислите все версии Node.js, доступные для установки:

Очевидно для Windows команда будет выглядеть примерно так:

Источник

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