nvm をインストールする
Travisにはデフォルトで nvm@0.32.0
がインストールされている(2017-05-31)
.travis.yml
language: ruby # not "node_js"
cache:
bundler: true
directories:
- node_modules
before_install:
# if package.json exists
- nvm install $(jq -r '.engines.node' package.json)
# Or if .nvmrc exists
- nvm install
package.json
{
"engines": {
"node": "6"
}
}
.nvmrc
6
See https://github.com/creationix/nvm#nvmrc.
最新の nvm
を使いたい場合
.travis.yml
before_install:
# Install nvm and Node.js (https://github.com/creationix/nvm#install-script)
- export NVM_VERSION=v0.33.0
- export NVM_DIR="$HOME/.nvm"
- rm -rf "$NVM_DIR"
- curl -o- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash
- . "$NVM_DIR/nvm.sh" || true # if .nvmrc exists then returns 3 exit status
- nvm install
See https://github.com/creationix/nvm#install-script.
Yarn を使う場合
.travis.yml
# https://docs.travis-ci.com/user/caching/
cache:
bundler: true
yarn: true
before_install:
# After nvm installation
# Install Yarn (https://yarnpkg.com/en/docs/install-ci#travis-tab)
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- yarn install