Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 3.81 KB

File metadata and controls

37 lines (29 loc) · 3.81 KB

Recommended Setup of Node.js on Windows

We recommend NVM for Windows to easily install, update and manage Node.js on our machines instead of directly installing it. As an added bonus, it allows you to switch between Node.js versions in a matter of seconds. If you’re on Linux, please follow this guide.

  • You can proceed with this guide if you need to perform a migration from an existing Node.js installation in this case, click here, or if you don't need to to perform any migration, skip to the section on setting up Node.js with NVM for Windows, click here.
  • Alternatively, you can install Node.js via its installer directly (we recommend the latest LTS version) and skip down to the Additional Configuration. However, we recommend against trying to maintain a Node.js installation this way.

Migration from an existing Node.js installation

  1. Optional: Backup any global npmrc config, e.g. %AppData%\npm\etc\npmrc. Alternatively, copy the settings to the user config %UserProfile%\.npmrc.
  2. Uninstall Node.js via Add or Remove Programs.
  3. Delete the Node.js installation directory %ProgramFiles%\nodejs by hand, should it remain.
    1. Using PowerShell: rmdir -r "$env:ProgramFiles\nodejs".
  4. Delete the NPM cache usually located in %AppData%\npm.
    1. Using PowerShell: rmdir -r "$env:AppData\npm".
  5. Go to the next section.

Setting up Node.js with NVM for Windows

  1. Close all Visual Studio instances.
  2. Install the latest release of NVM for Windows.
  3. Use the nvm-setup.exe from the list of assets.
  4. If your user folder contains accented characters or spaces, then in the installer wizard select a different path as the NVM installation location, which is free of those characters. Otherwise, nvm commands will fail later on.
  5. Open a new PowerShell window (or your favorite shell). Note: If you had a shell window open before running the NVM installer, it might not recognize the new nvm commands. Open a new window.
  6. Run nvm install lts. This will install the latest LTS version of Node.js.
  7. Run nvm use lts. This will activate the latest LTS version of Node.js as the current version.
  8. Should you need any other version of Node.js, e.g. for a certain client, run nvm list available, pick the desired version, and run nvm install and nvm use with that version.
  9. Skip down and follow Additional Configuration section.

Additional configuration

  1. You need to enable long paths to support the deep directory structure PNPM generates (after setting the long paths key, a reboot is necessary for the changes to take effect).
  2. Visual Studio users should add the Node.js installation path to the list of "External Web Tools" to ensure VS uses the same version that's used from the command line. To configure this:
    1. Start Visual Studio without opening any solution.
    2. Open Tools → Options → Projects and Solutions → Web Package Management → External Web Tools.
    3. Add C:\Program Files\NodeJs to the list and move it to the top.
  3. Install the NPM Task Runner extension for Visual Studio to execute any project’s node scripts, defined in their respective package.json, from the Task Runner Explorer window.