How to install NPM on Windows images

Using Powershell For NPM Install

If you need to use NPM on a windows executor you will find that this is not installed by default as part of the executor, but you can install it using PowerShell as an admin.

NPM Install Instructions

Below is a code block which can be used to install node version 16.17.0

     - run: choco install wget -y
      - run:
         command: wget https://nodejs.org/dist/v16.17.0/node-v16.17.0-x86.msi -P C:\Users\circleci\Downloads\
         shell: cmd.exe
      - run: MsiExec.exe /i C:\Users\circleci\Downloads\node-v16.17.0-x86.msi /qn
      - run: 
          command: |
              Start-Process powershell -verb runAs -Args "-start GeneralProfile"
              nvm install 16.17.0
              nvm use 16.17.0

The code will install wget using chocolatey which is included in the CircleCI windows executor to help install software on Windows. It then downloads node from the nodejs website to the Downloads folder of the CircleCI user using and runs the install in silent mode. Next powershell is run as admin using the Start-Process command. Finally nvm install is used to install the version 16.17.0and it is set as the version for node to be used using nvm use.

Outcome

You can run npm commands such as npm install to install the required software.

Additional Resources

Was this article helpful?
4 out of 6 found this helpful

Comments

0 comments

Article is closed for comments.