For a Laravel project I use Travis Ci with the language option as PHP. Besides PHP I want to do some Node JS testing. The default installed version of Node JS does not meet my requirements. How can I specify the version of Node JS in my config file?
I have tried the following. But unfortunately, that does not work.
language: php
php:
- '7.0'
- '7.1'
node_js:
- '6.10'
The n command for installing and activating a version of Node is simple: n 6.17. 1 . You could also use n latest for the latest version of Node or n lts for the latest LTS version of Node. If the version of Node is already installed, then n will simply switch to that version.
Just visit the Node installers page at https://nodejs.org/en/download/ and download and install the latest node version. From the “previous releases” section at the bottom of the page, you can select a specific version to install.
For npm install specific version, use npm install [package-name]@[version-number]. Use npm view [package-name] version to know the specific latest version of a package available on the npm registry. Use npm list [package-name] to know the specific latest version of an installed package.
In search for an answer to the same question I ended up here, and there, and this helped me:
language: php
php:
- 7.0
- 7.1
before_install:
- nvm install node
# "node" is an alias for the latest version
install
- npm install
Note: Installing this in the before_install
section as I am installing the actual packages in the install
section.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With