Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

".nvmrc" support? #727

Open
mdreizin opened this issue Apr 1, 2016 · 14 comments
Open

".nvmrc" support? #727

mdreizin opened this issue Apr 1, 2016 · 14 comments

Comments

@mdreizin
Copy link

mdreizin commented Apr 1, 2016

Does appveyor support .nvmrc out of the box?

@FeodorFitsner
Copy link
Member

Nope, because AppVeyor doesn't use NVM.

@mdreizin
Copy link
Author

mdreizin commented Apr 1, 2016

@FeodorFitsner 💔

@mdreizin
Copy link
Author

mdreizin commented Apr 1, 2016

@FeodorFitsner Have you any plans to support it?

@FeodorFitsner
Copy link
Member

What's use case here?

@mdreizin
Copy link
Author

mdreizin commented Apr 1, 2016

Using edge version of node and npm by using nvm.

It would be nice do not define nodejs configuration in appveyor.yml when you have .nvmrc:

environment:
  matrix:
    - nodejs_version: 4.2
    - nodejs_version: 4.1
    - nodejs_version: 4.0
    - nodejs_version: 0.12
install:
  - ps: Install-Product node $env:nodejs_version

appveyor should run nvm install && nvm use when .nvmrc is found.

For instance https://docs.travis-ci.com/user/languages/javascript-with-nodejs#Using-.nvmrc

@FeodorFitsner
Copy link
Member

I'm not familiar with NVM, but can you specify the same versions matrix in .nvmrc?

@mdreizin
Copy link
Author

mdreizin commented Apr 1, 2016

@FeodorFitsner No, you can't. You can specify only one version of node in .nvmrc.

For instance:

v5.9.0

@XhmikosR
Copy link
Contributor

XhmikosR commented Jul 6, 2016

There are solutions for Windows, but I believe nothing has become the standard like nvm on nix.

@nschonni
Copy link

Sorry for poking an old thread, but NVM itself points to https://github.com/coreybutler/nvm-windows
The benefit of using one of those managers is that you can point to any "index.tab"/"index.json" endpoint to install (ex: like Chakra or nightlys).

@westy92
Copy link

westy92 commented Jul 29, 2017

Although I'm not looking to use .nvmrc, I am hoping to use nvm (it doesn't run on Windows, but there are alternatives and there is a package via choco).

I like to use the latest version of Node.js that corresponds to each supported major version. For example, I say I want [4, 6, 7, 8] and I get the latest version of 4, etc.

I was disappointed that the versions available through AppVeyor are extremely limited and not the latest: https://www.appveyor.com/docs/build-environment/#node-js

In fact, there is a bug in npm that is fixed in a later version of Node that was causing my build to break. I had two options: find a way to install the latest Node.js (which for now includes this latest version of npm) or conditionally upgrade npm by itself when necessary.

I started going down the path to use choco to install the latest Node.js, but when I also wanted to specify the latest version 7, etc. I realized I would have to specify the entire version number.

I then tried installing nvm via choco, but I had to run refreshenv in order to use it which erased the environment variable(s) set in my build matrix.

If I had nvm, all I would have to do is:

environment:
  matrix:
    - nodejs_version: 8
    - nodejs_version: 7
    - nodejs_version: 6
    - nodejs_version: 4

install:
  - ps: nvm install $env:nodejs_version

As a temporary workaround for now, I added conditional npm upgrading:

environment:
  matrix:
    - nodejs_version: 8
      npm_version: 5
    - nodejs_version: 7
    - nodejs_version: 6
    
install:
  - ps: Install-Product node $env:nodejs_version
  - IF DEFINED npm_version (npm i -g npm@%npm_version%)

Furthermore, TravisCI uses nvm.

@FeodorFitsner
Copy link
Member

We've just updated Node.js 8.x up to the latest 8.2.1.

Actually, there is another Update-NodeJsInstallation cmdlet doing full re-install of Node.js thus giving you the latest: https://www.appveyor.com/docs/lang/nodejs-iojs/#installing-any-version-of-nodejs-or-iojs

@westy92
Copy link

westy92 commented Jul 29, 2017

Great! That's a better solution than what I had, thank you. Here's my final configuration:

environment:
  matrix:
    - nodejs_version: 8
    - nodejs_version: 7
    - nodejs_version: 6
    - nodejs_version: 4
    
install:
  - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)

@felixfbecker
Copy link

Btw, you can use ps-nvm for this (supports .nvmrc). You can install it in CI with Install-Module nvm.

@guidobouman
Copy link

guidobouman commented Jan 13, 2020

You can read .nvmrc and feed it to Install-Product:

Install-Product node (Get-Content ./.nvmrc) x64

If you want to be on the bleeding edge of LTS, you need something like the script below:

Update-NodeJsInstallation (Get-NodeJsLatestBuild (Get-Content ./.nvmrc)) x64

This, unfortunately, does not support al nvm aliases, but gets you started. Also, custom builds are quite slow. (They take a full minute to install) In my opinion, the node experience as a whole needs some love. See #3277 for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants