Before_install only on windows

I’m having errors only in one of my test tasks, particularly on Windows with the latest version of node. I googled it and apparently I need to run before install this

sudo npm install -g node-gyp

But how do I set my .travis.yml to run that just on windows? I suppose I don’t need sudo, but has windows environment admin rights?

My error log is this one:
https://api.travis-ci.org/v3/job/741738126/log.txt

does this work? I suppose not because it is bash

before_install:
  - if [ "$TRAVIS_OS_NAME" = "windows" ]; then npm install -g node-gyp; fi
  - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo npm install -g node-gyp; fi

This will work because commands in Windows builds are run with Git Bash.


AFAICS, those commands do work for you and the build fails later, at compilation stage.

Due to Stderr output is shown after the build log rather than inline, errors in a Windows build log are displayed at the end rather than where they belong.

It looks like the builder is getting 404s when trying to download some dependencies.

1 Like
Imprint