简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM