I have a create-react-app 3.0 project that is using Netlify functions. Everything is working great, but when I add the mysql module to a function I get errors and am unable to use it. I’ve seen a few posts on the github issues pages about webpack causing issue with these libraries. I know CRA has webpack working under the hood, but I don’t want it to touch my function files. I know tons of people use this library and there are relatively few issues reported about it, so I figure it’s an issue with how Netlify handles these or possibly even my configuration itself. I’ve tried adding a separate package.json for my functions folder but that doesn’t seem to solve the issue. I’ve been trying to fix this for days but with no success so any suggestions are greatly appreciated!
m-butler, can you post the errors you are seeing? That will help us quite a bit. Thanks for your patience.
While CRA does use webpack to bundle your react code, your lambda function won’t be bundled in to that React code. Also note that if the dependency won’t bundle then you don’t need to bundle it. You can deploy the function and it’s required
node_modules in a zip archive. There are a few ways to accomplish this with a coupe of examples being: