zxqx/generator-redux-stack

dependencies

vizmi opened this issue · 5 comments

vizmi commented

Hi,
I am relatively new to the yeoman scene it is possible I got something wrong, so threat this more like a question.
The generated code fails to run when installed with the npm install --production command - apparently this is how azure installs node web apps. The problem is: server side frameworks are listed as devDependency, which are ignored due to the --production flag. The app fails with http500, log shows

Error: Cannot find module 'express'

Is there a pre-installation step I am missing?

zxqx commented

Hey, sorry for just getting back to you on this.

So Yeoman allows you to set up generators to generate scaffolding (i.e. build tooling, folder structure, etc) for new projects.

The way you typically install a Yeoman generator is by installing it globally on your dev machine:

$ npm install generator-redux-stack -g

This will make the generator available on your machine so when you create new projects you can just do:

$ mkdir app-name && cd app-name
$ yo redux-stack

This command will prompt you with a few questions and then set up the infrastructure in your new project folder which allows you to immediately start writing your app.

Just to clarify, generators are not typically going to be part of the dependencies in your package.json.

vizmi commented

Sorry it seems I was not able to explain the problem clearly.
2nd attempt.
The generated package.json looks like this (copied from the template):

"devDependencies": { "babel": "^6.5.2", ... "express": "^4.13.4" ... }

now when you try to install the generated app on an another machine (i.e. production server) like this:
npm install --production
it won't install express, because devDependencies are skipped due to the --production flag.
The app could not be started because:
Error: Cannot find module 'express'

zxqx commented

Ah yeah, I see what you mean. In that case, I would suggest moving all your devDependencies to dependencies. This is something I have had to do when deploying directly to Heroku without a CI layer, as it uses npm install --production by default.

vizmi commented

In the mean time I have figured out what needs to be where, I can create a pull request with that if you are interested.
It might be useful for other users as well I guess.

zxqx commented

Going to close this issue for now. Feel free to open a PR if you have any ideas for improving this. Thanks!