Install npm (Node.js Package Manager) on Windows (w/o using Node.js MSI)

前端 未结 11 1952
孤独总比滥情好
孤独总比滥情好 2020-12-23 12:53

The problem: while using nvm to install Node.js I was able to install the version of Node.js I need, but nvm does not install npm auto

相关标签:
11条回答
  • 2020-12-23 12:55

    I used quite @Eyuel method:

    • Download the nodejs msi from https://nodejs.org/en/#download
    • Download npm zip from github https://github.com/npm/npm
    • Extract the msi (with 7 Zip) in a directory "node"
    • Set the PATH environment variable to add the "node" directory
    • Extract the zip file from npm in a different directory (not under node directory)
    • CD to the npm directory and run the command node cli.js install npm -gf

    Now you should have node + npm working, use theses commands to check: node --version and npm --version

    Update 27/07/2017 : I noticed that the latest version of node 8.2.1 with the latest version of npm are quite different from the one I was using at the time of this answer. The install with theses versions won't work. It is working with node 6.11.1 and npm 5.2.3. Also if you are running with a proxy don't forget this to connect on internet :

    • export http_proxy=http://proxy:8080
    • export https_proxy=http://proxy:8080
    • npm config set proxy http://proxy:8080
    0 讨论(0)
  • 2020-12-23 12:58

    Try going to Window -> Preferences -> Nodeclipse and unchecking the box that says "find node on PATH...". Then make sure the "Node.js path" below is set to the location of the node.exe file (for me it was C:\Program Files (x86)\nodejs\node.exe).

    0 讨论(0)
  • 2020-12-23 12:59

    Download the latest Node.js MSI (4.x or 5.x) installer and run the following via command line:

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

    This will extract the binaries into C:\Node.js\nodejs.

    Then you will want to add C:\Node.js\nodejs PATH environment variable.

    To update NPM, do the following:

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

    After that completes, you should be able to check the versions:

    node --version
    npm --version
    

    Node should be 4.4.3+ (whichever you installed) and npm should be 3.8.7+.

    0 讨论(0)
  • 2020-12-23 13:06

    https://nodejs.org/download/ . The page has Windows Installer (.msi) as well as other installers and binaries.Download and install for windows.

    Node.js comes with NPM.

    NPM is located in the directory where Node.js is installed.

    0 讨论(0)
  • 2020-12-23 13:06

    I also needed to install npm in Windows and got it through the Chocolatey pacakage manager. For those who haven't heard about it, Chocolatey is a package manager for Windows, that gives you the convenience of an apt-get in Windows environments. To get it go to https://chocolatey.org/ where there's a PowerShell script to download it and install it. After that you can run:

    chocolatey install npm
    

    and you're good to go.

    Note that the standalone npm is no longer being updated and the last version that is out there is known to have problems on Windows. Another option you can look at is extracting npm from the MSI using LessMSI.

    0 讨论(0)
  • 2020-12-23 13:06

    Just download "node.exe" from http://nodejs.org/dist/, select your favorite "node.js" version or take the latest. You can also take 64-bits version from "x64" sub-directory.

    Then, go to http://nodejs.org/dist/npm/ to retrieve Zip-archive of your favorite "npm" version (recommanded : 1.4.10). Extract the archive along "node.exe".

    Finally, it is recommanded to add "node.js" directory to the PATH for convenience.

    EDIT: I recommande to update npm using npm install npm -g because versions provided by nodejs.org are very old.

    If you want to keep original npm version, don't put npm alongside "node.exe". Just create a directory and use the same command with "global" flag, then copy .\node_modules\.bin\npm.cmd to the new directory :

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

    Finally change your PATH to use c:\app\npm\_latest

    0 讨论(0)
提交回复
热议问题