I'm implementing Passenger, on an Apache server (a Digital Ocean droplet, running Ubuntu 16.04), with a Node.js app. Webpack successfully builds the static .js file, and Node successfully runs the startup. However, when accessing the site from a browser, I get errors like Cannot find module 'app/path/to/file'
.
My app uses the NODE_PATH
environment variable to set the app source to ./src
so in import statements I don't have to set the path as src/app/path/to/file
, rather just app/path/to/file
. However, Passenger is modifying the NODE_PATH
variable, and when making a request to render the page, Node crashes Passenger because NODE_PATH
is no longer set to ./src
(however, during Node startup and Webpack build, NODE_PATH=./src
because Passenger is not involved in these processes).
So my question is, what is an alternative to setting NODE_PATH=./src
but still keeping the same effects (i.e src/app/path/to/file
=> app/path/to/file
).