christianalfoni / webpack-express-boilerplate

A boilerplate for running a Webpack workflow in Node express
MIT License
1.4k stars 292 forks source link

Express/server-side dependencies inside devDependencies? #59

Closed gtd closed 7 years ago

gtd commented 7 years ago

Today is my first day trying to build something with Node, so please bear with and let me know if this is a stupid question or I'm missing something obvious.

I am trying to deploy this boilerplate to Elastic Beanstalk. AWS has a prebuilt stack for a bunch of languages, and so I'm just relying on the default Node stack. It deploys successfully out of the box, but dependencies are not found and I get this error at https://github.com/christianalfoni/webpack-express-boilerplate/blob/master/server.js#L4:

Error: Cannot find module 'express'

If I move it into the main dependencies block then it fails on the next missing dependency. I guess the question is, how is this expected to work for production/staging deployments? Either I should be configuring EB to use the devDependencies or the server-side requirements should be in the main dependencies block. What is the intended usage here?

jorgenbs commented 7 years ago

npm install installs both dependencies and devDependencies. So make sure you have run that.

I agree that express should be inside dependencies (because its required to run the app). But practically it shouldn't matter in your case unless you are doing something like npm install --production.

gtd commented 7 years ago

Well the issue is that Elastic Beanstalk already has a pre-configured stack with its own poorly-documented script to handle the npm install, although it's probably possible to work around it, it's also generally a bad idea to go against the grain of the EB setup unless there is very good reason.

The annoying thing is that a bunch of these dependencies are only needed for the webpack build, which is only needed once per deploy. I suppose it could be cleaned up by building assets on a CI server and uploading to s3 instead of on the EB instance, but alas I don't have CI up yet.

Anyway, I'm understanding the lay of the land a lot better after a couple weeks and I'll figure something out. Thanks for the reply.