Alexander
Alexander

Reputation: 23

Why doesn't Travis CI run "npm install" with NODE_ENV production

I tried to compile my project in Travis CI with the following config:

language: node_js
node_js:
  - 0.12
env:
  global:
    - NODE_ENV=production
before_install:
  # - npm run init
before_script:
  # - bower install
  # - gulp
  # - npm install
script:
  - npm install -g bower
  - npm install -g gulp
  - gulp
  - npm run lint
sudo: false

If I set in my config

- NODE_ENV=production

Then Travis CI will compile my project.

Upvotes: 1

Views: 1908

Answers (1)

Dan Halliday
Dan Halliday

Reputation: 765

Travis CI does run npm install automatically — I suspect the problem you're having is with NODE_ENV and dependencies and devDependencies.

If NODE_ENV=production, NPM will not install devDependencies (as noted here: https://github.com/npm/npm/issues/6803). You need to make sure the dependencies you need are in the correct group:

  • NODE_ENV=production: dependencies installed from dependencies group
  • NODE_ENV=development: dependencies installed from devDependencies group

Upvotes: 8

Related Questions