Development Tip

Windows에서 npm을 어떻게 업데이트 할 수 있습니까?

yourdevel 2020. 10. 2. 23:25
반응형

Windows에서 npm을 어떻게 업데이트 할 수 있습니까?


나는 노력 :

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

...하지만 작동하지 않았습니다.

Windows에서 어떻게합니까?


이것은 Windows에서 npm업그레이드 하는 새로운 가장 좋은 방법 입니다.

관리자 권한으로 PowerShell 실행

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade

참고 : npm i -g npm. 대신 npm-windows-upgrade앞으로 npm을 업데이트 하는 데 사용하십시오 . 또한 NodeJS 설치 프로그램을 실행하면 노드 버전이 대체됩니다.

  • 노드가 설치된 위치에서 npm을 업그레이드합니다.
  • 쉬운 업데이트, npm-windows-upgrade -p -v latest.
  • 기본 경로를 수정하지 않습니다.
  • 기본 전역 패키지 위치를 변경하지 않습니다.
  • 쉽게 업그레이드 및 다운 그레이드 할 수 있습니다.
  • NPM 팀에서 공식적으로 추천합니다 .
  • NPM과 NODE간에 일치하는 버전 목록 ( https://nodejs.org/en/download/releases/)- 노드를 업데이트하려면 NODE INSTALLER를 다운로드하고 실행해야합니다 ( https://nodejs.org/en / )

최신 MSI를 다운로드 하고 실행합니다. MSI는 설치된 노드와 npm을 업데이트합니다.


NPM을 업데이트하기 위해 이것은 나를 위해 일했습니다.

  • 쉘에서 노드 설치 디렉토리로 이동하십시오. C:\Program Files (x86)\nodejs
  • 실행 npm install npm( -g옵션 없음 )

어떤 사람들처럼, 내가 필요한 복수 응답을 결합하고, 나는 또한 프록시를 설정하는 데 필요한.

이것은 해야 누군가를 위해 일한다. EXE 파일 또는 MSI 파일을 실행하고 싶지 않습니다. .. 제거 / 다시 설치하거나 파일과 폴더를 수동으로 삭제합니다. 1999 년이다.

  1. NPM을 업데이트하려면 다음을 실행하십시오.

    관리자 권한으로 PowerShell 실행

    npm i -g npm    // This works
    

    나는 하지 이 코드는 실제로 아래에 NPM 버전을 업그레이드 생각

    Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
    npm install -g npm-windows-upgrade
    npm-windows-upgrade
    
    (courtesy of "Robert" answer)
    

이것을 실행하여 Node.js를 업데이트하십시오.

wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files (x86)\nodejs\node.exe'    (courtesy of BrunoLM answer)

`wget : 경로의 일부를 찾을 수 없습니다 .... "**, 아래 참조 ... 스크롤 다운. 웹 응답 읽기 ... 최소한 방화벽 / 프록시를 뚫는 것입니다 (있는 경우 또는 이미 코드를 실행했습니다 ...

그렇지 않으면

프록시를 설정해야 할 수 있습니다.

npm config set proxy "http://proxy.yourcorp.com:811"    (yes, use quotes)

2 가지 가능한 오류

  1. 경로 솔루션 "where.exe node" (Lonnie Best Answer 제공)의 경로를 찾을 수 없습니다.

    예를 들어 Node.js가 where.exe와 함께 "Program Files (x86)"에 있지 않으면 'C : \ Program Files \ nodejs \ node.exe'에 있습니다.

    wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files\nodejs\node.exe'
    
  2. 이제 업그레이드를 시도하지만 "node.exe가 다른 프로세스에서 사용되고 있습니다."라는 또 다른 오류가 발생 합니다.

    • / shutdown 다른 콘솔 .. 명령 프롬프트 및 PowerShell 창 등을 닫습니다. 명령 프롬프트에서 npm을 사용하는 경우에도 닫습니다.

npm -v (3.10.8)

노드 -v (v6.6.0)

끝난. 내가 원하는 버전에 있습니다.


Windows 용 패키지 관리자 인 Chocolatey사용할 수 있습니다 (예 : Debian Linux 용 apt-get).

새로 설치 (이전에 설치된 버전을 제거해야 할 수 있음)

> choco install nodejs

최신 버전으로 업데이트

> choco update nodejs

및 npm

> choco update npm

다음 명령을 사용하여 npm을 최신 안정 버전으로 업데이트 할 수 있습니다.

 npm install npm@latest -g

PowerShell을 사용하여 실행하십시오. 이 명령은 Windows 관리자 권한이 필요하지 않으며 다음을 사용하여 결과를 확인할 수 있습니다.npm -v


이전 답변은 Node.js의 새 버전 (아마도 가장 좋은 옵션)을 설치하는 데 작동하지만 특정 Node.js 버전에 대한 종속성이있는 경우 "npm install npm -g"가 작동합니다. 명령 전후에 npm -v를 실행하여 확인합니다.

여기에 이미지 설명 입력


이것은 Windows 7 x64에서 npm을 업데이트하는 데 잘 작동합니다.

  • Windows 시작
  • 모든 프로그램
  • Node.js
  • Node.js 명령 프롬프트 (대체 클릭)
  • 관리자 권한으로 실행

    $ npm -g install npm

  • C:\Program Files\nodejs\npm.cmd새로운 npm을 제거 하십시오.C:\Users\username\appdata\roaming\npm\npm.cmd

도움이 되었기를 바랍니다.


관리자 권한으로 PowerShell을 엽니 다.

처음 설치하려면이 작은 스크립트를 사용하여 최신을 다운로드 msi하고 실행할 수 있습니다.

$nodeLatest=((curl https://nodejs.org/download/release/latest/).Content | findstr x64.msi) -replace "<(.*?)>", "" -replace "\s+.+", "";
wget "https://nodejs.org/download/release/latest/$nodeLatest" -OutFile (join-path $env:TEMP node.msi); Start-Process (join-path $env:TEMP node.msi)

향후 업그레이드에서 node.exenpm을 다운로드 하여 업데이트 할 수 있습니다.

wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files\nodejs\node.exe'
npm i -g npm

이제 최신 노드와 npm이 있어야합니다.


나는 조금 더 나아가 nvmWindows 용 을 구현하기로 결정했습니다 .

https://github.com/brunolm/nvm

Install-Module -Name power-nvm

nvm install latest
nvm default latest

1. 최신 npm 버전 설치

npm install –g npm@latest 

( "npm –version"을 입력하여 확인할 수 있습니다.)


2. 노드 설치

ㅏ. 다음 URL을 통해 노드 새 버전을 설치합니다. https://nodejs.org/en/download/current/ 기본 선택 사항을 따릅니다
. b. C : \ Users \\ AppData \ Roaming \ NPM 제거
c. C : \ Users \\ AppData \ Roaming \ npm-cache 제거


선택적으로 :

디. (현재 프로젝트 폴더에서 node_modules 폴더 삭제)
e. npm 캐시 확인
f. npm 설치


Windows에서 업그레이드 npm 사용

Windows에서 npm을 업그레이드하는 사용자를위한 공식 문서입니다!

여기 내 스크린 샷이 있습니다!

여기에 이미지 설명 입력


Node.js를 업데이트하는 방법 :

  1. Uninstall Node.js. Click the Start menu, type "Change or Remove a Program", click on the item shown, find Node.js in the list and uninstall it.

  2. Delete directories, both C:\Program Files (x86)\nodejs\ and C:\Program Files\nodejs\ if they exist.

  3. Install the latest, https://nodejs.org/en/download

    The uninstall/delete/install seems unnecessary, but it often is and this will save your time.     These instructions come from Microsoft.

How to Update NPM:

    https://www.npmjs.com/package/npm-windows-upgrade

    This is the official documentation for upgrading npm on windows.

All was tested and working on Windows 10 (2017).


For what it's worth, I had to combine several answers...

  1. Uninstall Node.js in control panel Add/remove programs.
  2. Delete directories, both C:\Program Files (x86)\nodejs\ and C:\Program Files\nodejs\ if they exist.
  3. Install the latest version, http://nodejs.org/download/

this is best tool to maintain version of NODE.Js i NVM

Node Version Manager (nvm) for Windows but for Windows, with an installer. Download Now! This has always been a node version manager, not an io.js manager, so there is no back-support for io.js. However, node 4+ is supported. 여기에 이미지 설명 입력


For me, after totally uninstalling node. 10.29, and then installing node 4.2.2, there remained a 10.29 node.exe file in my c:\windows folder.

I found this by using the following command:

where.exe node

The command returned:

C:\Windows\node.exe
C:\Program Files\nodejs\node.exe

So even though I had successfully installed version 4.2.2 via the msi executable, the command "node -v" would continue to return 10.29.

I resolved this by deleting this file:

C:\Windows\node.exe

I followed @josh3737 and installed the latest MSI from the node.js homepage.

But I had the additional problem that I still had the old node and npm on the command line. The problem was caused by the new installation, that it was installed into

C:\Program Files (x86)\nodejs\

instead of the previous installation in

C:\Program Files\nodejs\

The new installation added the new directory into my path variable after the old one. So the old installation was still the active one in the path. After removing C:\Program Files\nodejs\ from system path and C:\Users\...\AppData\Roaming\npm from user path and restarting the command line the new installation was active.

Maybe the least path was a local problem that has nothing to do with the new installation, I had two links to AppData\Roaming\npm in it. And maybe this can also be fixed by first uninstalling node.js and installing the new version afterwards.


This works fine for me

  1. Run Command Prompt as Administrator

  2. Navigate to the folder containing nodejs (eg. C:\Program Files\nodejs)
  3. Run Powershell -ExecutionPolicy Unrestricted

  4. Run npm-windows-upgrade

  5. This will show list of versions available to install. Just select your desired version by moving up/down key & Press Enter.

    This'll update your npm
  6. To check the current version of npm

    Run npm --version

Command Prompt Screenshot


I was also facing similar issues. I followed below mentioned steps and it worked for me:

  • go to Windows > Start > Node.js

    • right click on Node.js command prompt
    • click on Run as administrator
  • ping registry.npmjs.org

  • npm view npm version

  • cd %ProgramFiles%\nodejs

  • npm install npm@latest

and npm updated successfully. Earlier I was trying for CMD and that was throwing error. may be some path issue that got resolved by running NodeJs Command Prompt. hope it'll work for you. try this.


To install the updates, just download the installer from the Nodejs.org site and run it again. The new version of Node.js and NPM will replace the older versions.


The easiest way I found so far to update Node.js is using Chocolatey. Use Chocolatey to install or update the latest version of Node.js on Windows:

Step 1: First, ensure that you already have Chocolatey installed. If not, use an administrative shell to install chocolatey through cmd.exe or PowerShell.exe. For more information, visit: https://chocolatey.org/docs/installation

Step 2: Install with cmd.exe. Run the following command:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

To install with PowerShell.exe, visit: https://chocolatey.org/docs/installation

Step 3: Install or Update with following commands on cmd.exe (on administrative mode)

To Install Node.js: cinst nodejs.install

To Update Node.js: cup nodejs.install


OK guys, I read (tried on Windows) all the previous stuff and all of these answers have their own disadvantages.

For the best way to update Node.js (at least for me), go to https://nodejs.org/en/ Then download the last version and install it in same folder you installed the previous version in - 1 min and it's done. You don't need to remove any old files.

Then update npm typing in cmd: npm install --save latest-version


For NodeJS

Download required node version msi from here and install

for Npm

Run PowerShell as Administrator

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade

follow these steps for window 10 or window 8

  • press WIN + R and type cmd and enter
  • npm i -g npm@next
  • npm i -g npm@next OR npm i -g node@{version}
  • Remove environment path C:\Program Files\nodejs from envrionment variable PATH.
  • type refreshenv in cmd

Now you will have your new version which you installed.

Note: If you don't remove path. You will see the previous version of node.


Powershell does not execute npm directly, I suggest using

.\npm install -g npm-windows-upgrade
.\npm-windows-upgrade

and it failed with:

You wanted to install npm 6.1.0, but the installed version is 3.10.10.

A common reason is an attempted "npm install npm" or "npm upgrade npm". As of today, the only solution is to completely uninstall and then reinstall Node.js. For a small tutorial, please see http://aka.ms/fix-npm-upgrade.

Please consider reporting your trouble to http://aka.ms/npm-issues.

http://aka.ms/fix-npm-upgrade <-- this is a dead link


You can use these commands:

npm cache clean
npm update -g [package....]

If you are upgrading from a previous version of node, then you will want to update all existing global packages. You can also specify the package name to be updated.


This might help someone. Neither "npm-windows-upgrade" nor the installer alone did it for me. Powershell was still using an older version of node and npm.

So this is what I did (worked for me): 1. Download the latest installer from nodejs.org. Install node. It will update your node; everywhere (Powershell, cmd etc.). 2. Install the npm-windows-upgrade package (npm install -g npm-windows-upgrade) and run npm-windows-upgrade.

I didn't uninstall anything and didn't set any paths.


In my case, I discovered that I had two copies of Node.js installed. One under "C:\Program Files\nodejs" and another under "C:\Program Files (x86)\nodejs".


This is what worked for me.

  1. Open a local folder other than the one in which nodejs is installed.
  2. Install npm in that folder with command npm install npm
  3. Navigate to the folder containing node js. (C:\Program Files\nodejs\node_modules)
  4. Delete the npm folder and replace it with the npm and bin folders in the local folder.
  5. Run npm -v. Now you would get updated version for npm.

Note: I tried installing npm directly in "C:\Program Files\nodejs\node_modules" but it created errors.


  1. Start
  2. Search for windows powershell
  3. Right click and run as administrator
  4. Type: where.exe node (returns the path of node.exe in your system. Copy this)
  5. wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'PATH-OF-NODE.EXE_WHICH_YOU_COPIED_JUST_NOW'
  6. To check if it has worked, go to your Git bash/Normal command prompt and type: node -v
  7. Here you can find the current version of node: https://nodejs.org/en/blog/release/

참고URL : https://stackoverflow.com/questions/18412129/how-can-i-update-npm-on-windows

반응형