Hello, I’m working on transferring a NextJS site over to Netlify, and I’m having trouble resolving an error:
Runtime.ImportModuleError: Error: Cannot find module 'follow-redirects'
Require stack:
- /var/task/.netlify/functions-internal/___netlify-handler/handlerUtils.js
- /var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js
- /var/task/___netlify-handler.js
- /var/runtime/index.mjs
at _loadUserApp (file:///var/runtime/index.mjs:997:17)
at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1032:21)
at async start (file:///var/runtime/index.mjs:1195:23)
at async file:///var/runtime/index.mjs:1201:1
I’m using this command to do the deploy:
netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_ACCESS_TOKEN --build --prod --skip-functions-cache
I’ve included these dependencies in my package.json:
"@netlify/plugin-nextjs": "~4.37.4",
"@netlify/functions": "~1.6.0"
My netlify.toml config looks like this:
[[plugins]]
package = "@netlify/plugin-nextjs"
[build]
publish = ".next"
[build.environment]
NEXT_DISABLE_NETLIFY_EDGE = "true"
I’m using node 16.20.0. The project lives in a monorepo managed by rushjs using pnpm. The only information I’ve been able to find on the error message is that I need to include public-hoist-pattern[] = follow-redirects
in my .npmrc file, but that doesn’t solve the error either.
Any ideas what I might be missing or what I can do to debug this? Since these are auto-generated Netlify functions creating this error and I don’t have any Netlify functions of my own I’m not sure how to get Netlify to properly find its dependencies.
Thanks for any help!