Next js Build failing on production environment while deploying in netlify

Hi Team ,

I have deployed my next js project to netlify. On adding ENV = “test” in environmental variables for next.config.js file build is successful but on setting ENV=“production” the build is failing as show in below screenshots , event though the below errors are not showing in local build , all modules are present.

Its been a week since this has not been resolved , can any one help me out of this ?

production skips installing devDependencies. You should remove that.

actually I have shifted from vercel to netlify , in vercel i didn’t faced any issue with production environment for devDependencies , but in netlify i am facing this issue . Here in my application without devDependencies I am not able to build my next js application in netlify .

This is the default Node.js behaviour, not something Netlify can or should control: Manage build dependencies | Netlify Docs

please check this :
Screenshot 2024-12-26 212430

having same NODE_ENV in both vercel and netlify as production but vercel is working and netlify isn’t.

I really got stucked here.

Did you try removing that? We can go over in circles unless you decide to try removing the variable.

Yeah I’ve tried it , by removing node_env variable . It seems build with out node_env by default considering as test environment so dev dependencies are also being imported as well. But production env isn’t resolved .

The solution is to move everything to dependencies instead of devDependencies. I’d advise you to read more about Node.js, npm and package.json to understand the consequences of doing what you are doing.