Fylke
Fylke

Reputation: 1836

How to deal with dependencies when deploying a node.js app?

I'm setting up a gulp build file for a node.js project and I really don't have any experience with either of them.

So basically what I'm doing is simply copying all the code to a deployment directory, but I'm unsure of how to handle all the dependencies that are stored in node_modules. Do you simply copy all of them as well, or is there a more preferred way of doing it?

gulp.task('deliver', function() {
  gulp.src('src/*.html').pipe(gulp.dest('deployment/'));
  gulp.src('src/*.js').pipe(gulp.dest('deployment/'));
  gulp.src('src/games/').pipe(gulp.dest('deployment/'));
});

Upvotes: 0

Views: 192

Answers (1)

Matthew Arkin
Matthew Arkin

Reputation: 4648

The standard way would be to have a package.json file that lists all your dependencies. Then as part of your deployment process run npm install which will go through your package.json and install any necessary packages in the node_modules folder.

Upvotes: 2

Related Questions