leepowell
leepowell

Reputation: 3688

Add to NODE_PATH on Heroku/Foreman

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.

Upvotes: 2

Views: 829

Answers (1)

Marc Greenstock
Marc Greenstock

Reputation: 11668

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

Upvotes: 1

Related Questions