1

I am currently trying to run the following command, this has been working seemlessly but most recently in our builds it is failing.

- script: npm install --legacy-peer-deps
      workingDirectory: $(rootFolder)
      displayName: 'NPM install'

npm ERR! command sh -c node-pre-gyp install --fallback-to-build

I assume this is because NPM is pulling from the latest build in the deployment pipeline in Azure. I cannot see where any nodejs or npm is being installed during it other than this command.

How can I downgrade the npm version used in the pipeline?

Update: I have tried the following with no luck:

- script: npm -g npm@14.21.3
  workingDirectory: $(rootFolder)
  displayName: 'Downgrade NPM Version'
Jaquarh
  • 6,493
  • 7
  • 34
  • 86

1 Answers1

3

Since npm is bundled with with Node you should probably just lock in which node version you want using NodeTool before you run npm install.

  - task: NodeTool@0
    displayName: 'Set Node.js version to 16.x'
    inputs:
      versionSpec: '16.x'

However, I'm not sure that this is just a version problem. I've seldom had problems where npm have been the culprit, and since the error mentions node-pre-gyp I would rather think that it failed to get the correct binaries and had to fall back to building (and failed that for some reason).

Karl-Johan Sjögren
  • 16,544
  • 7
  • 59
  • 68
  • 1
    I managed to reproduce the problem locally via upgrading my NPM version to the version the pipeline was using, this lead to me downgrading locally and fixing the issue (temp) so as a temp solution this has worked perfect for me! Thankyou! Long term, I need to assert how to upgrade these dependencies but I feel that this will have major breaking changes that will need a session in its own. Thanks Karl! – Jaquarh Feb 22 '23 at 13:54
  • Great that it worked out! – Karl-Johan Sjögren Feb 22 '23 at 13:55
  • 1
    Great timing. Azure just upgraded from node 16 to 18, which may cause the [digital envelope routines](https://stackoverflow.com/q/69692842/4978821) error. Might be an influx of people stumbling upon this like me ;) – l p Feb 22 '23 at 18:13
  • That explains why 17.x was not working locally as I assumed Azure would of bumped the versions. I could not find the last supported version so I had to use 16.21.X which was the latest one that worked for my dependencies. Thanks for that additional information – Jaquarh Feb 22 '23 at 20:40