Can not find module (when running with pm2)


I installed a node module with npm and added
to the environment.

When I start n8n with:
node node_modules/.bin/n8n

I can use the module with require.

But once I start it with pm2:
pm2 start node node_modules/.bin/n8n

the module is not available anymore and it says “Can not find module”

Any idea what I missed here ?


Hey @passana,

Has the environment variable been added to the pm2 ecosystem file? I am not sure how pm2 handles modules and if it needs anything else to be done.

thanks @jon . I thought, that pm2 passes all the env from the current session.

with ecosystem file it worked. Thanks for the hint.

1 Like