Gelin Luo
Gelin Luo

Reputation: 14373

Gulp build does not install dependencies automatically?

I use gulp to build my javascript application. I have some dependencies declared in the package.json file, for example:

"dependencies": {
  "flux": "^2.0.1",
  "keymirror": "~0.1.0",
  "object-assign": "^1.0.0",
  "react": "^0.13.1",
  "dropzone": "^4.0.1",
  "lodash": "^3.6.0"
}

When I run gulp build, it always prompt me some dependency cannot be found unless I manually run npm install lodash for example.

Is there a way to have gulp run npm install automatically?

Upvotes: 29

Views: 44121

Answers (3)

halogenr
halogenr

Reputation: 339

gulp-install would help for your issue. Go to NPM (node package manager) and search for "gulp-install".

The node plugin gulp-install automatically installs packages/dependencies for npm, bower, tsd, and pip. The relative configurations must be found in the gulp file stream.

Example Usage:

In your gulpfile.js:

var install = require("gulp-install");

gulp.src(["./package.json", "./bower.json"])
  .pipe(install());

Upvotes: 4

Alex
Alex

Reputation: 531

Run npm install --save-dev command to resolve all dependencies.

Here is link to documentation with --save-dev parameter description: https://docs.npmjs.com/cli/install

Upvotes: 43

Vikas Kathunia
Vikas Kathunia

Reputation: 61

  1. You require to have package.json on the root level.
  2. Then once you have to run npm install for all the dependencies with --saveDev(development dependencies) or --save(project level dependencies).
  3. Once this is done, for the next time only run npm install command will install dependent dependencies.

Upvotes: 6

Related Questions