Is it possible to have a separate node_modules folder for devDependencies?

I have a Node application that I am deploying to Heroku. In your documents, it is recommended to use node_modules in your directory (i.e. not gitignore it), for faster it also deploys dev / prod.

In my package.json I have loaded devDependencies (mostly Grunt plugins and all their depics) and several regular serial dependencies such as Express. Herok needs only industrial waste. I would prefer not to check all my maiden depots, because they reach approximately 50 MB.

Is there a way to have a separate folder for you dev deps, for example. node_modules_dev ? If it were possible, I could just add node_modules_dev to my .gitignore and check the node_modules directory in the regular version as recommended by Heroku.

Is there any way to do this? Or can you think of another way to do what I'm trying to do?

+7
heroku node-modules
source share
2 answers

I use the CI server to build, test and deploy my files, so I was looking for a similar solution that would prevent me from deploying additional dependencies and / or re-building on Heroku.

After all my tests, I run npm prune --production , which removes devDependencies from node_modules , and then I click the result in Geroku.

No additional files are sent to the server, and the deployment time is much faster, since Heroku avoids the need to create all the binaries commonly found in Gulp / Grunt plugins.

+2
source share

If you don't mind checking them anyway, and your only problem is the result of the bullet size (i.e. not your git repository size or transferring this repo to Heroku), just add the appropriate node_modules to .slugignore .

Documents: Ignore files with .slugignore .

+1
source share

All Articles