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

前端 未结 11 1953
孤独总比滥情好
孤独总比滥情好 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 13:08

    I wrote a quick simple app recent that handle the management of various version of node and npm. It allows you to choose different version of node and npm to download and select which version to use. Check it out and see if it's something that's useful.

    https://github.com/nhatkthanh/wnm

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

    First CD to where node(nodejs) is installed using windows CMD, then follow the steps below

    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
    
    0 讨论(0)
  • 2020-12-23 13:13

    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

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

    To install npm on windows just unzip the npm archive where node is. See the docs for more detail.

    npm is shipped with node, that is how you should install it. nvm is only for changing node versions and does not install npm. A cleaner way to use npm and nvm is to first install node as it is (with npm), then install the nvm package by npm install nvm

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

    TL;DR: Install Chocolatey, Node (and NPM)

    Install Chocolatey

    NOTE: You might want to copy the exact command from their install page since it might change over time.

    1. Open your standard Windows command line
    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. Restart console
    4. Done!

    Install Node (and NPM)

    1. Because Chocolatey installs a directory different from the MSI installation, go to your system configuration and delete your previous node installation (if you have one)
    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


      (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!

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