IT story

Windows에 npm (Node.js 패키지 관리자) 설치 (Node.js MSI를 사용하지 않음)

hot-time 2021. 1. 7. 20:00
반응형

Windows에 npm (Node.js 패키지 관리자) 설치 (Node.js MSI를 사용하지 않음)


문제 : nvmNode.js를 설치 하는 동안 필요한 Node.js 버전을 설치할 수 있었지만 자동으로 nvm설치되지는 않습니다 npm. NPM 페이지는 설치에 대한 정보를 제공하지 않습니다. 나 자신이 Windows 사용자가 아니기 때문에 완전히 헤매고 있습니다 ...

Google의 모든 결과는 Node.js MSI 설치 프로그램을 사용하여 작동하는 것으로 보입니다. 이것은 제 경우에는 옵션이 아닙니다. 그래서 어떻게합니까?


Windows에 npm을 설치하려면 노드가 있는 npm 아카이브의 압축을 풉니 다 . 자세한 내용은 문서참조하십시오 .

npm은 노드와 함께 제공되므로 설치해야합니다. nvm은 노드 버전 변경 전용이며 npm을 설치하지 않습니다. npm 및 nvm을 사용하는 더 깨끗한 방법은 먼저 노드를있는 그대로 (npm 사용) 설치 한 다음 다음을 수행하여 nvm 패키지 를 설치하는 것입니다.npm install nvm


https://nodejs.org/download/ . 이 페이지에는 Windows Installer (.msi)와 기타 설치 프로그램 및 바이너리가 있습니다. Windows 용 다운로드 및 설치.

Node.js는 NPM과 함께 제공됩니다.

NPM은 Node.js가 설치된 디렉토리에 있습니다.


나는 꽤 @Eyuel 방법을 사용했습니다.

  • https://nodejs.org/en/#download 에서 nodejs msi를 다운로드합니다.
  • github https://github.com/npm/npm 에서 npm zip 다운로드
  • "node"디렉토리에서 msi (7 Zip 포함)를 추출합니다.
  • "node"디렉토리를 추가하려면 PATH 환경 변수를 설정하십시오.
  • 다른 디렉토리 (노드 디렉토리 아님)의 npm에서 zip 파일을 추출하십시오.
  • npm 디렉토리에 CD를 넣고 명령을 실행합니다. node cli.js install npm -gf

이제 노드 + NPM 작업을해야 사용이 논문 명령은 확인 : node --versionnpm --version

업데이트 27/07/2017 : 최신 버전의 npm을 사용하는 노드 8.2.1의 최신 버전이이 답변 당시 사용했던 것과 상당히 다르다는 것을 알았습니다. 이 버전으로 설치하면 작동하지 않습니다. 노드 6.11.1 및 npm 5.2.3에서 작동합니다. 또한 프록시로 실행하는 경우 인터넷에 연결하는 것을 잊지 마십시오.


또한 Windows에 npm을 설치해야했고 Chocolatey pacakage 관리자를 통해 가져 왔습니다. 들어 본 적이없는 사람들을 위해 Chocolatey는 Windows 용 패키지 관리자로, Windows 환경에서 편리하게 사용할 수 있습니다. 다운로드 및 설치를위한 PowerShell 스크립트가있는 https://chocolatey.org/이동 하십시오. 그 후에 다음을 실행할 수 있습니다.

chocolatey install npm

그리고 당신은 갈 수 있습니다.

독립형 npm은 더 이상 업데이트되지 않으며 최신 버전은 Windows에서 문제가있는 것으로 알려져 있습니다. 살펴볼 수있는 또 다른 옵션은 LessMSI를 사용하여 MSI에서 npm을 추출하는 입니다.


Windows CMD를 사용하여 node (nodejs)가 설치된 첫 번째 CD, 다음 단계를 따르십시오.

C:...\node> git config --system http.sslcainfo /bin/curl-ca-bundle.crt
C:...\node> git clone --recursive git://github.com/isaacs/npm.git
C:...\node> cd node=modules\npm
C:...\node=modules\npm> node cli.js install npm -gf

http://nodejs.org/dist/ 에서 "node.exe"를 다운로드하고 좋아하는 "node.js"버전을 선택하거나 최신 . "x64"하위 디렉토리에서 64 비트 버전을 가져올 수도 있습니다.

그런 다음 http://nodejs.org/dist/npm/ 으로 이동 하여 좋아하는 "npm"버전의 Zip 아카이브를 검색합니다 (권장 :) 1.4.10. "node.exe"를 따라 아카이브를 추출하십시오.

마지막으로 편의를 위해 "node.js"디렉토리를 PATH에 추가하는 것이 좋습니다.

편집 : npm install npm -gnodejs.org에서 제공하는 버전이 매우 오래 되었기 때문에 npm을 업데이트 하는 것이 좋습니다.

원래 npm 버전을 유지하려면 npm을 "node.exe". 디렉토리를 만들고 동일한 명령을 "global"플래그와 함께 사용한 다음 .\node_modules\.bin\npm.cmd새 디렉토리에 복사 하십시오.

mkdir c:\app\npm\_latest
cd c:\app\npm\_latest
<NPM_ORIGINAL_PATH>\npm install npm
cp node_modules\.bin\npm.cmd npm.cmd

마지막으로 사용할 경로를 변경하십시오. c:\app\npm\_latest


최근에 다양한 버전의 노드 및 npm 관리를 처리하는 간단한 앱을 작성했습니다. 다른 버전의 노드와 npm을 선택하여 다운로드하고 사용할 버전을 선택할 수 있습니다. 그것을 확인하고 그것이 유용한 지 확인하십시오.

https://github.com/nhatkthanh/wnm


Window-> Preferences-> Nodeclipse로 이동하여 "find node on PATH ..."상자를 선택 취소하십시오. 그런 다음 아래의 "Node.js 경로"가 node.exe 파일의 위치로 설정되어 있는지 확인합니다 (저는 C : \ Program Files (x86) \ nodejs \ node.exe).


최신 Node.js MSI (4.x 또는 5.x) 설치 프로그램을 다운로드하고 명령 줄을 통해 다음을 실행합니다.

msiexec /a node-v4.4.3-x64.msi /qb TARGETDIR="C:\Node.js"

바이너리를 C:\Node.js\nodejs.

그런 다음 C:\Node.js\nodejs PATH환경 변수 를 추가하고 싶을 것 입니다.

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

cd C:\Node.js\nodejs
npm install npm@latest

완료되면 버전을 확인할 수 있습니다.

node --version
npm --version

노드는 4.4.3+ (설치 한 항목) 여야하며 npm은 3.8.7+ 여야합니다.


요약 : Chocolatey, Node (및 NPM) 설치

Chocolatey 설치

참고 : 시간이 지남에 따라 변경 될 수 있으므로 설치 페이지 에서 정확한 명령을 복사 할 수 있습니다.

  1. 표준 Windows 명령 줄을 엽니 다.
  2. @powershell -NoProfile -ExecutionPolicy unrestricted -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH="%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
  3. 콘솔 다시 시작
  4. 끝난!

노드 (및 NPM) 설치

  1. Chocolatey는 MSI 설치와 다른 디렉토리를 설치하므로 시스템 구성으로 이동하여 이전 node설치를 삭제하십시오 (있는 경우).
  2. Install Chocolatey as described above
  3. choco install nodejs

    NOTE I used nodejs. I am not even sure what node is, but having had my fair share of troubles with node already being taken by something else in other systems, I thought, nodejs would be the safer bet right away

  4. Restart your console
  5. Beware: node -v works!
    • And npm -v also works! Awesome.

After this, I was able to install firebase-tools without problems (which I was not able to do previously), so something must have gone terribly right! :)

My rather complete story the first time around

"Chocolatey installs in seconds"

If you don't care about sarcasm or lamenting engineers on a Sunday afternoon, skip ahead to the installation instructions in the TL;DR section below.

For everyone else: I want to amend this answer which recommends using (what seems to be the hottest package management solution for Windows right now): Chocolatey

It gets the job done nice and quick. However, when I gave it a first try, it took me a while to make sense of the install instructions which are kinda convoluted. The install instructions go a bit like this (complete with what went through my head while going through it):

  • NOTE:
  • NOTE:
  • NOTE:

    three big-ass NOTEs before even knowing the basics... this makes me anxious... how wrong could things go!?

  • Installing With Restricted TLS

    not even sure what TLS is... Oh it's a good friend of SSL - Shouldn't this just be the default and just work out of the box? My browser can do HTTPS, NO PROBLEM! (just kidding... I know that SSL and TSL frequently cause a lot of pain in environments that have high security needs)

  • Option 1
  • Option 2

    eeh... great... Can't I just install?

  • Installing Behind a Proxy?

    Just... no...

  • Requirements

    uh boi...

  • Why does Chocolatey install where it does by default?

    Seriously!?!

  • Before You Install

    sad
    (source: clipartbest.com)

  • Can I install with a proxy?

    again with the proxy...

  • Can I install a particular version of Chocolatey?

    just any version would be fine, thank you...

  • Can I use Windows built-in compression instead of downloading 7zip?

    7zip?! Why do you even mention this?!

  • Non-Administrative Install
  • Now that sounds great!

    • "NOTE: This option should be a last resort and is considered to be an advanced scenario."
      • Sh$%!@T.

  • Alternative Installation Options

    giddy

  • Command Line
    • "This really is the easiest method because it requires no configuration of PowerShell prior to executing it."

      And there you go!

While I really appreciate the fact that pitfalls and their possible solutions are discussed so extensively, maybe re-organizing them as such, and putting the Chocolatey installs in seconds promise to work by putting the "easiest method" first would be just awesome!


If you're running Windows 10 Creators Update (1703) and are comfortable navigating around a Unix terminal, you could potentially achieve this using the native Feature Bash on Ubuntu on Windows (aka Bash/WSL)

This was originally introduced on the launch of Build 2016 but many additions and bug fixes were addressed at the Creators update but please be warned this is still in Beta.

To enable simply navigate to Control Panel\All Control Panel Items\Programs and Features\Turn Windows features on or off

Then select the Windows Subsystem for Linux (Beta) as below Bash on Windows Feature

ReferenceURL : https://stackoverflow.com/questions/16000173/install-npm-node-js-package-manager-on-windows-w-o-using-node-js-msi

반응형