- Как обновить npm и пакеты npm ?
- Обновление npm на windows 10
- Дополнительная информация
- Похожие записи
- Ubuntu. В разделе /boot не осталось места.
- Ubuntu 18.04 Punto Switcher
- npm set registry
- Lets Encrypt Wildcard SSL вручную
- Open Windows Terminal in current folder
- Интерактивные и удобные linux инструменты
- Как обновить Node.js на Windows, Linux и Mac
- Как обновить Node.js на Windows
- Другие способы установки и обновления Node.js на Windows
- Как обновить Node.js на Linux
- Как обновить Node.js на Mac
- How to Update Node.js to Latest Version PHP Code Home Web Servers 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. Download the following dependencies by typing: 3. Install NVM using the curl command: 4. Close and reopen the terminal. 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: n stable Install the latest release: n latest Install a specific version: n [version.number] 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. 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. How do I update npm on Windows? When I install node 0.10.33 from the msi ( http://nodejs.org/download/ ), I get an old version of npm (1.4.28). How can I upgrade npm on Windows? npm install -g npm does not work; I still have the old npm. 12 Answers 12 tl;dr — npm -g install npm does work, but the old version of npm is still in your PATH. To fix this, do one of these: C:\Program Files (x86)\nodejs\npm C:\Program Files (x86)\nodejs\npm.cmd Option 3: Open cmd.exe as administrator, navigate to C:\Program Files (x86)\nodejs and then run the installation without -g: npm install npm@latest *There is an npm package that automate this Option 3: We at Microsoft Open Source wrote a small tool to automate the process outlined above. You can find it here or just install and run it by executing the following in an elevated command prompt / PowerShell: + CategoryInfo : ObjectNotFound: (npm-windows-upgrade:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException – Dan Csharpster May 3 ’16 at 18:42 There May be many ways to update your npm in Windows Way 1 Open you power shell as Administrator and run following commands step by step. Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force npm install -g npm-windows-upgrade npm-windows-upgrade Here you can select your preferred version of npm Ready to go ! Way 2 You can simply upgrade to the latest npm version with following command npm install npm@latest -g or if you want a specific version of npm simply run npm install npm@ -g for example npm install npm@3.3.12 -g Now simply run npm —version or npm -v to know your current version of npm 3.3.12 is my preferred version of npm that best suits for approximately every package. So, TL;DR; this worked: From a command prompt, run where npm If you had npm installed via chocolatey, you’ll see a path like C:\ProgramData\chocolatey\bin\npm.exe — DELETE it! Now install NodeJS using the appropriate MSI from https://nodejs.org/en/download/ In your favourite shell, type npm —version — this should now echo the version of NPM that came with NodeJS (at the time of this writing, that version is 3.10.10)
Как обновить npm и пакеты npm ?
Чтобы обновить нужный проект, выполните команду
Сама по себе такая комада редка нужна. Чаще нужно обновить npm пакеты проекта за записью новых версий в package.json, для этого в корневой директории проекта выполните команду
Как всегда, есть нюанс. Update обновляет пакеты в соответствии с записями из package.json , поэтому надо учитавать знаки больше/меньше, тильды, крышки и равно. Если пакет задан как = 1.0.67, то npm update его не обновит.
Если нужно поставить версии пакетов, отличные от записей в package.json, то следует воспользоваться командой npm install
Пара примеров, обновим глабально Angular CLI и Storybook CLI
Обновим npm через npm в рамках минорной версии
Обновим npm через npm с переходом на последнюю мажорную версию
Обновление npm на windows 10
На windows есть определённые проблемы с обновлением, если npm установлен вместе с nodejs. В этом случае лучше воспользоваться npm-windows-upgrade. Правая кнопка мыши по меню «Пуск» -> запуск консоли от имени администратора.
Далее следует ввести 3 команды и следовать инструкциям
Дополнительная информация
Посмотреть версию установленного пакета
Посмотреть устаревшие пакеты
Посмотреть последнюю версию пакета в репозитарии npm (которая устанавливается по npm i )
Например, посмотреть версию последней альфы Storybook CLI
Похожие записи
Ubuntu. В разделе /boot не осталось места.
Недавно столкнулся с проблемой, что система ubuntu не может обновиться. Пишет ошибки про неудвлетворенные зависимости и не дает возможности завершится командам.
Ubuntu 18.04 Punto Switcher
Нормальной замены на Ubuntu нет, есть gxneur, но он кривой(( Пытался пользоваться несколько месяцев. В итоге удалил.
npm set registry
Lets Encrypt Wildcard SSL вручную
Определение wildcard SSL. Краткий список шагов ручного получения бесплатного wildcard SSL-сертификат от Lets Encrypt на примере CentOS 7 и утилиты acme.sh
Open Windows Terminal in current folder
Add setting «startingDirectory»: «.» in terminal profile CTRL + ,
Интерактивные и удобные linux инструменты
Обновленные альтернативы инструментов командной строки cat, ncdu/du, ls, find, jq
Как обновить Node.js на Windows, Linux и Mac
Этим вопросом задаются многие новички. Они не знают правильного и эффективного способа, и именно для них наш сегодняшний материал. Стоит отметить, что вариантов, как обновить Node.js достаточно много. Я постараюсь рассмотреть каждый из них в отдельности, включая, кстати, операционные системы, на которых будут производиться нужные действия.
Как обновить Node.js на Windows
Самым простым и очевидным способом здесь будет использование готового Bash-скрипта для Windows. С его помощью можно не только установить актуальную версию Node.js, но и произвести другие, не менее важные операции. Например, вы можете установить сразу несколько версий Node.js, и переключать их в зависимости от своих потребностей. Реализуется это через специальные команды:
Само обновление же можно воспроизвести и с помощью такой последовательности действий:
Очищаем кэш NPM:
Устанавливаем менеджер версий Node.js n:
Выбираем нужную версию Node.js:
1. Стабильная версия
2. Последняя версия
3. Установка определенной версии
4. Удаление определенной версии
Помимо всего прочего, вы можете загрузить актуальную версию Node.js на официальном ресурсе Node.js. Там доступны установочные пакеты MSI, архивы zip и tar.gz, также версии для Linux и Mac.
Другие способы установки и обновления Node.js на Windows
В 2017 году на разных ресурсах описывают еще один, более актуальный способ, который был рекомендован одним из зарубежных «гуру» в своем блоге. Чтобы обновить Node.js нам нужно воспользоваться таким алгоритмом:
Узнаем какую версию Node мы используем:
Просмотрим доступные для установки версии, а также используемую:
Выведем список доступных версий:
Установим нужную версию (предположительно 1.1.1):
Для включения более старой версии используем команду:
Не могу ничего сказать по поводу эффективности данного метода, однако вы можете самостоятельно проверить его, после чего отписать в комментариях о результате.
Также вы можете использовать этот, самый простой, по моему мнению, способ:
1. Запускаем cmd от имени администратора
2. Последовательно выполняем две команды:
Данный способ рекомендован разработчиками npm, поэтому вам стоит обратить внимание на него.
Как обновить Node.js на Linux
Как и в случае с Windows, здесь мы будем использовать менеджер npm. Здесь он доступен по другому адресу на GitHub. Большая часть команд совпадает с вышеописанными, поэтому вам следует лишь повторить их, предварительно установив NPM на свою версию Linux.
Кстати говоря, если вы используете Arch Linux (или производные дистрибутивы), обновление для Node.js будет установлено автоматически при следующем апгрейде системы.
Как обновить Node.js на Mac
И снова здесь актуален способ с NPM, вы можете использовать абсолютно те же команды, что и для Windows с Linux. Однако сейчас мы рассмотрим альтернативной вариант, подразумевающий работу с менеджером пакетов Homebrew.
После установки вам достаточно будет выполнить одну единственную команду:
How to Update Node.js to Latest Version PHP Code
- Home
- Web Servers
- 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. Download the following dependencies by typing:
3. Install NVM using the curl command:
4. Close and reopen the terminal.
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: n stable
- Install the latest release: n latest
- Install a specific version: n [version.number]
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. 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.
How do I update npm on Windows?
When I install node 0.10.33 from the msi ( http://nodejs.org/download/ ), I get an old version of npm (1.4.28). How can I upgrade npm on Windows?
npm install -g npm
does not work; I still have the old npm.
12 Answers 12
tl;dr — npm -g install npm does work, but the old version of npm is still in your PATH.
To fix this, do one of these:
C:\Program Files (x86)\nodejs\npm
C:\Program Files (x86)\nodejs\npm.cmd
Option 3: Open cmd.exe as administrator, navigate to C:\Program Files (x86)\nodejs and then run the installation without -g:
npm install npm@latest
*There is an npm package that automate this Option 3:
We at Microsoft Open Source wrote a small tool to automate the process outlined above. You can find it here or just install and run it by executing the following in an elevated command prompt / PowerShell:
+ CategoryInfo : ObjectNotFound: (npm-windows-upgrade:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException – Dan Csharpster May 3 ’16 at 18:42
There May be many ways to update your npm in Windows
Way 1
- Open you power shell as Administrator and run following commands step by step.
- Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
- npm install -g npm-windows-upgrade
- npm-windows-upgrade
- Here you can select your preferred version of npm
- Ready to go !
Way 2
- You can simply upgrade to the latest npm version with following command
- npm install npm@latest -g
- or if you want a specific version of npm simply run
- npm install npm@
-g for example npm install npm@3.3.12 -g
Now simply run npm —version or npm -v to know your current version of npm
3.3.12 is my preferred version of npm that best suits for approximately every package.
So, TL;DR; this worked:
From a command prompt, run where npm
This is what worked for me (goofy me!) I had (age ago) installed npm via chocolatey, which created a chocolatey initiated npm.exe in C:\ProgramData\chocolatey\bin\npm.exe. This was npm version 1.4.9 and wouldn’t update no matter what one did including uninstall and reinstall NodeJs.
EDIT: Better way to install node and npm
As of today (27/06/2017), the best way to install and manage node and npm is to install nvm (Node Version Manager) as explained here: https://github.com/coreybutler/nvm-windows. Once you have nvm, installing any node version is super easy:
- Open your favourite console (CMD, Cmder, PowerShell)
- Type nvm install 6.10.2 (to install node version 6.10.2)
- To see the currently active version, type nvm list . This prints something like below:
You need to follow the Windows upgrade instructions
First, ensure that you can execute scripts on your system by running the following command from an elevated PowerShell. To run PowerShell as Administrator, click Start, search for PowerShell, right-click PowerShell and select Run as Administrator.
- Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
- npm install —global —production npm-windows-upgrade
- npm-windows-upgrade
Want to just install the latest version? 1.npm-windows-upgrade —npm-version latest
I did something similar to Sam Mikes. I’m only sharing this because I couldn’t get either of his solutions to work on my rig. After a bit of playing around, this is what worked for me:
- Remove NPM/Node from your Environment Variables, both for user and system.
- Close your open console if you have one open, then open a console as administrator
- Change directories to %USERPROFILE% — that’s a window’s environment variable that takes you to C:\Users\CurrentlyLoggedInUser
- Run from the console in %USERPROFILE%, «C:\Program Files\nodejs\npm» install npm -g (you might have yours in the x86 folder)
- If this solution would work for you, step 4 would have worked, and npm -v will show a an up-to-date version
- Re-add Node (in Program Files)/NPM (in App Data — the one installed in Program Files should be the old one) to your user and system environment variables
Note: I’ve used the Microsoft automated script in the past to fix this, but only because I didn’t realize how easy it would be to do it myself.
So none of the previous answers solved the issue for me so I thought I would post my specific solution, which I managed to figure out by going through all the other answers so they were really helpful.
My issue was because I had used chocolatey to install node and possibly npm (looking at chocolatey site now I shouldn’t have done that).
To solve the issue I simply had to run the relevant choco uninstall commands for npm and node and then everything switched to the other version of node which I had also installed using the node msi (from node’s website).
I hope that helps anyone else that may have gone down the same path as me.
Use npm-windows-upgrade tool to simply upgrade. Steps are provided in the link.
I tried almost every answer but none of them works my way.
Neither npm-windows-upgrade worked nor did the npm install npm@latest etc etc worked.
For people like me I will suggest you guys downloading the latest installer from Node.js website, let the existing version of node directory be on it’s place and without changing anything just install the msi installer and you will end up with an upgraded version of node.
My case was upgrading node from 6 to 8.9.3
all npm install commands were getting stuck and will throw error (behind proxy error) after sometime. setting up proxy was not helping. This is what I did.
- Uninstalled NodeJS from Programs & Features with the uninstaller.
- Reboot (or you probably can get away with killing all node-related processes from Task Manager).
- Look for these folders and remove them (and their contents) if any still exist. Depending on the version you installed, UAC settings, and CPU architecture, these may or may not exist: • C:\Program Files (x86)\Nodejs • C:\Program Files\Nodejs • C:\Users
\AppData\Roaming\npm (or %appdata%\npm) • C:\Users \AppData\Roaming\npm-cache (or %appdata%\npm-cache) • C:\Users .npmrc (and possibly check for that without the . prefix too) - Check your %PATH% environment variable to ensure no references to Nodejs or npm exist.
- If it’s still not uninstalled, type where node at the command prompt and you’ll see where it resides — delete that (and probably the parent directory) too.
- Reboot, for good measure.