State of Netlify Functions after Netlify Dev?

Hey Everyone, I am new here. But not new to Netlify, been using it from a year now. Absolutely love it and after Netlify Dev, It’s been a joy to develop sites. However, I am very confused with the working of Netlify functions. I am developing them by using Netlify Dev, Everything works fine locally. But It crashes saying that Unable to find the module in production. I am confused because I don’t know If I have to compile the function or not. I read this article by Chris and I am also doing the same thing except using sendgrid’s module and the error is cannot find module @sendgrid/mail. But in this, he does not seem to compile it. Tough he is developing locally but according to him, we should not compile. So please clarify if we have to compile or not?


no you dont have to compile, however if your functions require node_modules, you will have to install them when in production because you are probably git ignoring your node_modules. so in your build script do something like npm run build && cd src/functions/myfunction && npm i or the equivalent in yarn if yarn applies to you

1 Like

Make sure the node modules are installed locally in that function directory

This is an example of how to install function deps during the build process

1 Like