ino_fleg
ino_fleg

Reputation: 87

Increase the version of npm in Azure DevOps pipeline

I have a YAML pipeline on Azure DevOps for building our client-side scripts via npm. The problem is that the pipeline is using version '6.14.13'. I would like to use a newer version that I am using locally, in this case, '7.19.1'. I ran npm install npm@latest -g at the start of the pipeline. However, it did not help as the next call to npm --version or when running e.g. npm i the pipeline's output to the console is displaying the old version '6.14.13'.

Thank you for your help.

Upvotes: 1

Views: 5550

Answers (2)

Favo Yang
Favo Yang

Reputation: 314

Run npm install npm@latest -g will only update the system npm.

The Npm@1 task shipping with Azure DevOps is using an npm installation at a custom location i.e. /opt/hostedtoolcache/node/12.22.12/x64/bin/npm. To update the Azure DevOps's npm, using the Npm@1's custom command like below,

- task: Npm@1
  inputs:
    command: custom
    customCommand: 'install -g npm@latest'
  displayName: 'Upgrade npm to latest version'

Upvotes: 3

RKM
RKM

Reputation: 1389

We can use command the following command to update the package.json version.

npm version <newversion>

For example, current version is v1.0.1, using command npm version 2.0.0 will update its version to v2.0.0.

Please note that the version format must be the same, like major.minor.patch.

Upvotes: -2

Related Questions