Unable to switch Node.js versions using nvm in Bitbucket pipeline on Windows runner

Yogesh Kumar September 5, 2024

 

 

I have installed nvm on my Windows runner and successfully installed two Node.js versions: 16.15.0 and 6.9.1. When I try to switch between these versions manually using the command nvm use {version} on the runner, it works as expected.

However, when I try to switch between Node.js versions using the same nvm use {version} command in the Bitbucket pipeline YAML file, it doesn't work. The pipeline doesn't switch the Node.js version as intended.

Here are the details:

  • Operating System: Windows
  • nvm-windows is installed, and I can switch Node.js versions manually.
  • The pipeline fails to switch the version programmatically using nvm use {version} in the script.

How can I achieve this Node.js version switch within the Bitbucket pipeline?

Any help or examples would be greatly appreciated!

2 answers

0 votes
Tobias Schlüter
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 20, 2024

Same here, the pipeline just hangs on execution of the (any, actually) `nvm` command.

- nvm help -> hangs

- nvm list -> hangs

- nvm use -> hangs

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 20, 2024

Hi Tobias,

Please see my reply below:

https://community.atlassian.com/t5/Bitbucket-questions/Re-Re-Unable-to-switch-Node-js-versions-using-nvm-in-Bi/qaq-p/2875317/comment-id/109539#M109539

If you are still experiencing issues, please create a new question in community via https://community.atlassian.com/t5/forums/postpage/board-id/bitbucket-questions and we will look into it.

Kind regards,
Theodora

Tobias Schlüter
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 20, 2024

That fixed it. Appreciate it!

Like Theodora Boudale likes this
0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 6, 2024

Hi Yogesh,

May I know which build image you are using in your YML configuration, and if you are performing install commands for both versions as part of your build script?

I will also need the error you're receiving.

Cheers!

- Ben (Bitbucket Cloud Support)

 

Yogesh Kumar September 6, 2024

Hi Ben, I'm using window server 2019 as runner. Im using following commands through script:

          - nvm use 6.9.1
          - npm install
          - npm run postinstall
          - npm run build
But my node version is not switching to 6.9.1
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 20, 2024

Hi Yogesh,

Are you still experiencing issues with this?

If so, can you please let me know what version of nvm-windows do you have installed on this server?

You can find that out by running

nvm --version

I was able to reproduce this with nvm version 1.1.12. My Windows machine was also showing the error indicated in this issue:

As per the suggestions on this issue, I uninstalled nvm and then installed again the nvm version 1.1.11, and then the commands worked as expected from the Pipelines build.

Can you please give it a try?

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events