appveyor / ci

AppVeyor community support repository
https://www.appveyor.com
344 stars 65 forks source link

".nvmrc" support? #727

Open mdreizin opened 8 years ago

mdreizin commented 8 years ago

Does appveyor support .nvmrc out of the box?

FeodorFitsner commented 8 years ago

Nope, because AppVeyor doesn't use NVM.

mdreizin commented 8 years ago

@FeodorFitsner 💔

mdreizin commented 8 years ago

@FeodorFitsner Have you any plans to support it?

FeodorFitsner commented 8 years ago

What's use case here?

mdreizin commented 8 years ago

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 commented 8 years ago

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

mdreizin commented 8 years ago

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

For instance:

v5.9.0
XhmikosR commented 8 years ago

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

nschonni commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

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

guidobouman commented 4 years ago

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.