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?
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.
Как скачать и установить Node.js и NPM на Windows
Node․js — это среда‚ которая включает в себя все необходимое для выполнения программы‚ написанной на JavaScript․ Он используется для запуска сценариев на сервере для отображения содержимого перед его доставкой в веб-браузер․
NPM означает Node Package Manager‚ который является приложением и хранилищем для разработки и совместного использования кода JavaScript․
Это руководство поможет вам установить и обновить Node․js и NPM в системе Windows и другие полезные команды Node․js․
Шаг 1 ։ Загрузите установщик Node․js
В веб–браузере перейдите по адресу https։//nodejs․org/en/download/․ Нажмите кнопку установщика Windows‚ чтобы загрузить последнюю версию по умолчанию․ На момент написания статьи последней версией была версия 12․14․1–x64․ Установщик Node․js включает в себя менеджер пакетов NPM․
Примечание․ Доступны и другие версии․ Если у вас более старая система‚ вам может потребоваться 32–разрядная версия․ Вы также можете использовать верхнюю ссылку для переключения со стабильной версии LTS на текущую версию․ Если вы новичок в Node․js или вам не нужна конкретная версия‚ выберите LTS․
Шаг 2։ Установите Node․js и NPM
1․ Как только установщик завершит загрузку‚ запустите его․ Откройте ссылку для загрузки в вашем браузере и щелкните файл․ Или перейдите в папку‚ в которой вы сохранили файл‚ и дважды щелкните его‚ чтобы запустить․
2․ Система спросит‚ хотите ли вы запустить программное обеспечение – нажмите « Выполнить»․
3․ Вас приветствует мастер установки Node․js – нажмите Далее․
4․ На следующем экране просмотрите лицензионное соглашение․ Нажмите Далее‚ если вы согласны с условиями и установите программное обеспечение․
5․ Программа установки предложит вам указать место установки․ Оставьте расположение по умолчанию‚ если у вас нет особой необходимости устанавливать его где–либо еще – затем нажмите Next․
6․ Мастер позволит вам выбрать компоненты для включения или удаления из установки․ Опять же‚ если у вас нет особой необходимости‚ примите значения по умолчанию‚ нажав Далее․
7․ Наконец‚ нажмите кнопку Install‚ чтобы запустить программу установки․ Когда он закончится‚ нажмите Готово․
Шаг 3 ։ Проверьте установку
Откройте командную строку ‟или PowerShell” и введите следующее։
Система должна отображать версию Node․js‚ установленную в вашей системе․ Вы можете сделать то же самое для NPM։
Как обновить Node․js и NPM в Windows
Самый простой способ обновить Node․js и NPM – это загрузить последнюю версию программного обеспечения․ На странице загрузки Node․js‚ прямо под ссылкой установщика Windows‚ будет отображаться последняя версия․ Вы можете сравнить это с версией‚ которую вы установили․
Для обновления скачайте установщик и запустите его․ Мастер установки перезапишет старую версию и заменит ее новой версией․
Как удалить Node․js и NPM в Windows
Вы можете удалить Node․js из панели управления в Windows․
Нажмите кнопку Пуск > Настройки ‟значок шестеренки”> Приложения․
Прокрутите вниз‚ чтобы найти Node․js и нажмите‚ чтобы выделить․
Выберите Удалить․ Это запускает мастер для удаления программного обеспечения․
Npm update npm windows
🚀 Upgrade npm on Windows
Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Upgrade npm on Windows
Upgrading npm on Windows requires manual steps to ensure that PowerShell/CMD find the new version of npm. This is a small tool made with ❤️ for npm and Node, reducing the process to a simple command.
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 .
Then, to install and use this upgrader tool, run the following command (also from an elevated PowerShell or cmd.exe). Note: This tool requires at least Node v8, please install an older version for older versions of Node.js.
Want to just install the latest version? Sure:
The tool will show you a list of all the published and available versions of npm (including pre-release and beta versions). Choose the one you want to install and let it do its thing!
Usage: npm-windows-upgrade [options]
If you have trouble with the script, consider adding parameters manually. A common issue is that the script fails to find npm (and therefore doesn’t know where to install it) — in that case, pass the location manually.
To manually specify a version to install, pass the version parameter:
To override the internet connection check, pass —no-dns-check . To disable the initial prompt, pass —no-prompt .
To see debug output, set a DEBUG environment variable ( $env:DEBUG=»npm-windows-upgrade» )
Please do report your issues on GitHub. There are a bunch of Windows versions, hundreds of different ways to install Node and npm, and it’s likely that this script won’t work with a few of them. If you run into trouble and need npm upgraded as soon as possible, please follow the manual instructions.
This tool was made with ❤️ for npm and Node, but it is provided «as is», without warranty of any kind, expressed or implied. For details, please consult the LICENSE file.
Fix an Attempted Upgrade
Chances are that you attempted to upgrade npm before, it somehow failed, and you then went looking for this tool. If the tool fails to upgrade, it may be troubled by partial changes done during npm install npm or npm upgrade npm . In that case, you will have to completely uninstall Node:
- Uninstall Node.js (select Uninstall , not the Repair option).
- Go into %programfiles%\nodejs and delete the entire folder.
- Delete %appdata%\npm and %appdata%\npm-cache .
- Edit your PATH and remove everything that references npm (to do so, hit «Start» and search for «Environment Variables»).
- Reinstall Node, then install this tool — and only use this tool to upgrade npm, do not attempt to run npm install npm .
:memp: Used Chocolatey? If you used Chocolatey (https://chocolatey.org/) to install Node.js, be sure to check if npm is removed from the choco\bin directory by running the following command: where.exe npm . Should it still be there, you will need to either choco uninstall npm or delete the files from this bin directory.
Older Node.js Versions
- For Node versions lower than v8.0, please use npm-windows-upgrade@5.0.0
- For Node versions lower than v6.0, please use npm-windows-upgrade@4.1.1
- For Node versions lower than v4.0, please use npm-windows-upgrade@3.1.1
More Useful Node.js Stuff
Microsoft is working hard to make sure that our users have the best possible experience with Node.js. For a helpful set of content that makes it easier to avoid any potential gotchas, go check out our Node.js Guidelines — a collection of tips and advanced best practices!
Contributions are extremely welcome! For JavaScript code, please run grunt test to check your code against JSCS and JSHint. There’s no formal coding guideline for the PowerShell pieces of this tool, but do write code that is commented and comprehensible.
MIT, please see LICENSE for details. Copyright (c) 2015 — 2017 Felix Rieseberg.