node.jsgitlabgitlab-ci-runnernvmgitlab-runner

How to use nvm in user-mode through Gitlab on Windows?


I use GitLab and I have several projects using different versions of node. I came across the nvm-windows project, and installed it on my local machine to try it out.

$ nvm install 14.18.0
$ nvm use 14.18.0

raises an exception:

exit status 1: You do not have sufficient privilege to perform this operation.

I installed the nvm package without admin priviledges into the HOME directory, so no system path is involved. I believe that mklink is to blame here as this is used to create some symbolic links.

This would mean, that I need to run the Gitlab client in admin rights, but I want to avoid this. What would be the most common approach to use a pipeline with different node versions?


Solution

  • As it has been said here, just execute the following line and make sure it is git-tracked to solve the problem.

    node --version > .nvmrc
    

    and Add the following line to the package.json file:

    "scripts": {
        "v": "node -v"
    }