Home
Support Forums

Analyze Netlify functions "included_files" for static imports

I am trying to use shopify-api-node in my Netlify functions but I’m facing MODULE_NOT_FOUND errors because the library uses dynamic imports.

Netlify provides the included_files property to allow for the manual addition of files.
However, even after including the entire library like so included_files = ["node_modules/shopify-api-node/**"], I am still facing MODULE_NOT_FOUND errors for third-party libraries such as lodash which are imported by shopify-api-node via static imports.

I can fix these errors by adding lodash to included_files but it would be a dramatically better developer experience if Netlify analyzed the included_files for static imports like it does for other dependencies which are discovered naturally.

What makes this worse is that netlify dev runs flawlessly and the MODULE_NOT_FOUND errors only manifest on production.

Edit: moved it its own post in the Support section

Hi @citylights

Wondering if you have seen these posts from the Netlify Blog which might provide some more information on achieving dynamic imports.

Yes, of course. Although, to be frank, after reading those docs it’s still not clear to me how these two configurations differ:

included_files: ["node_modules/shopify-api-node/**"]
vs
external_node_modules: ["shopify-api-node"]

included_files is used to include files like JSON, .env, xslx or any kind of files that might be needed by your functions.

external_node_modules is used to bundle npm packages specifically.