- we need to know your netlify site name. Example:
gifted-antelope-58b104.netlify.app
https://dev--treasury-front.netlify.app
Hello! I’m experiencing some problems deploying a Next.js application. The main page loads properly but when trying to log in I receive an error. I have tried several things and the error changes but I can’t get past it.
The original error was:
Runtime.ImportModuleError - Error: Cannot find module '../../../../../../../node_modules/next/dist/server/next-server.js' Require stack: - /var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js - /var/task/___netlify-handler.js - /var/runtime/index.mjs
Then I followed advice here and downgraded to "@netlify/plugin-nextjs": "4.36.1",
and the error changed to
Runtime.ImportModuleError - Error: Cannot find module './node-environment' Require stack: - /var/task/src/apps/node_modules/next/dist/server/next-server.js - /var/task/src/apps/treasury/next-frontend/src/apps/treasury/next-frontend/.netlify/functions-internal/___netlify-handler/___netlify-handler.js - /var/task/___netlify-handler.js - /var/runtime/index.mjs
At some point making changes (which I can completely isolate) the error changed to
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
I don’t think it is related to the monorrepo because I reproduced it outside of it.
In case it helps here is my package.json
and netlify.toml
{
"dependencies": {
"@auth0/nextjs-auth0": "^3.1.0",
"@context/shared": "^0.0.1",
"@context/treasury": "^0.0.1",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@netlify/next": "^1.4.9",
"@netlify/plugin-nextjs": "4.36.1",
"date-fns": "^2.30.0",
"follow-redirects": "^1.15.2",
"formidable": "^3.5.1",
"next": "^13",
"prop-types": "^15.8.1",
"react": "^18",
"react-datepicker": "^4.16.0",
"react-dom": "^18",
"react-icons": "^4.2.0",
"react-pdf": "^7.3.3",
"react-toastify": "^9.1.3",
"tailwindcss": "^3.2.1",
"zod": "^3.22.2"
},
"devDependencies": {
"@next/eslint-plugin-next": "^13.4.19",
"@swc/core": "^1.3.84",
"@swc/jest": "^0.2.29",
"@testing-library/cypress": "^10.0.0",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/formidable": "^3.4.2",
"@types/jest": "^29.5.4",
"@types/jest-axe": "^3.5.5",
"@types/node": "^20.6.0",
"@types/prop-types": "^15.7.5",
"@types/react": "^18",
"@types/react-datepicker": "^4.15.0",
"@types/react-dom": "^18",
"@types/react-pdf": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"autoprefixer": "^10.3.4",
"cypress": "^13.2.0",
"eslint": "^8.49.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-next": "13.4.19",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-module-resolver": "^1.5.0",
"file-loader": "^6.2.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest-axe": "^8.0.0",
"jest-environment-jsdom": "^29.7.0",
"jest-transform-stub": "^2.0.0",
"postcss": "^8.3.6",
"typescript": "5.2.2",
"typescript-eslint": "^0.0.1-alpha.0"
},
"resolutions": {
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7"
}
}
[build]
command = "yarn build"
publish = ".next"
[[plugins]]
package = "@netlify/plugin-nextjs"
# This is a fake plugin, that makes it run npm install
[[plugins]]
package = "@netlify/plugin-local-install-core"
Thanks in advance