Requiring modules external to functions directory

I’ve tried requiring shared utility-type modules that live outside my functions directory and get a Error: Cannot find module '../utils' message when the function is run after being deployed. Interestingly, the error is not thrown when running the function locally using netlify dev.

I was wondering if this is expected or if it should be possible to require modules that are outside the functions directory.

hi, this isn’t allowed in netlify in production. and is a mistake in netlify dev allowing it. we will fix in due time.

Thanks for confirming.

I got around my problem by putting the shared modules in a lib folder inside the functions directory. Are there any drawbacks to or recommendations against that approach?

no i think that is fine :slight_smile: