Note that there are some explanatory texts on larger screens.

plurals
  1. POHow should I handle node module dependencies in an application with a plugin based architecture on Heroku?
    text
    copied!<p>I'm working on a node.js based framework/server. This framework starts an express server and automatically loads all plugins from a local directory. The framework and individual plugins each have their own git repository.</p> <p>The framework is here: <a href="https://github.com/Appsecute/appsecute-connector-multi" rel="nofollow">https://github.com/Appsecute/appsecute-connector-multi</a> (see server.js for plugin loading). </p> <p>An example plugin is here: <a href="https://github.com/Appsecute/appsecute-connector-multi-heroku" rel="nofollow">https://github.com/Appsecute/appsecute-connector-multi-heroku</a> (see connector.js for the plugin definition/bootstrap file). </p> <p>This all works fine locally. Now it's time to get it deployed to Heroku. My plan was to write a small script that cloned the framework + specified plugins and built a folder structure that was ready to be deployed.</p> <p>I have written this script here: <a href="https://github.com/Appsecute/appsecute-connector-multi-deployment" rel="nofollow">https://github.com/Appsecute/appsecute-connector-multi-deployment</a></p> <p>Now, on to my question, is it possible to instruct Heroku to do an 'npm install' in both the root of the application (the framework), as well as specific subdirectories (each of the plugins)?</p> <p>I know node will look inside the nearest node_modules folder relative to the script that is loading the modules, so if a plugin tries to load a module then node will first look in app_root/plugins/plugin_name/node_modules - which is exactly what I want, I just need Heroku to make sure the modules are there.</p> <p>I was initially planning on letting my build script go to the various directories and run an npm install, but then I remembered Heroku will do its own npm install. </p> <p>My other option is to write some code that inspects all the dependencies in each plugins package.json file, then do a union on all the dependencies and write them out in to the package.json in to the root of the app. This way when Heroku does its npm install then all dependencies will be installed. This sounds brittle and will probably fail when different plugins specify a different version of the same module.</p> <p>And all this finally begs the question, am I just doing this wrong? Should I be looking at a different architecture/repo structure etc.?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload