Is it possible to add NODE_PATH in Heroku/Foreman, I can't seem to find anything in the docs, and I'd like to load custom modules from my lib directory.
I've tried the following in my .env file and loaded it locally with Foreman and it doesn't seem to work:
NODE_PATH=/path/to/lib/directory
The environment variable gets loaded but not picked up by Node as I get module not found errors.
Two options here, add export the the beginning of your variable declaration:
export NODE_PATH=/path/to/lib/directory
Without export the variable is only available within the shell and not available to sub processes
Option 2, prefix your foreman start with the declaration of the variable
NODE_PATH=/path/to/lib/directory foreman start
This will make the variable available within the foreman process and it's child processes