kross kross - 5 months ago 25
Node.js Question

travis-ci ruby build with node 5

I've tried many things, but have ultimately failed to get the build for gulp-pipeline-rails running. The

script
runs locally, no problem.

The last problem I've narrowed down is that I have a
ruby
language project that utilizes node, but I need node 5. I found one snippet:

#------------------------------
# Update the node version
env:
- TRAVIS_NODE_VERSION="5"

install:
- pwd
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
- npm install


While this seems to get node updated, it does something to my ruby env where it fails to execute rspec:

$ pwd && bundle exec rake
/home/travis/build/alienfast/gulp-pipeline-rails
Could not find gem 'rspec' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.





Question
With all that said, how do I simply use Node 5 with this
.travis.yml
?

language: ruby
rvm:
- 2.2.2
- ruby-head

matrix:
allow_failures:
- rvm: ruby-head

cache: bundler

#------------------------------
# Setup
before_script:
- node -v
# update npm
- npm install npm -g

# install Gulp 4 CLI tools globally from 4.0 GitHub branch
- npm install https://github.com/gulpjs/gulp-cli/tarball/4.0 -g

#------------------------------
# Build
script: bundle exec rake

Answer

Try using a before_install stage for adding a second language on Travis, maybe something like:

before_install:
  - nvm install node

nvm should be installed by default on the Travis build image (depending on which one you're using), and this command will install the latest version of Node.

After that, maybe just have npm install -g gulp-cli@4.0 as the first step in your before_script stage (i.e. don't worry about updating npm), hopefully that should mean that bundler still runs fine and installs all your gems.

Comments