Next.js ^14.2.3 build is throwing typescript, and sometimes eslint, error on vercel but locally it works fine. Its not that typescript or eslint fails but vercel does not have typescript/eslint package while building hence throws error:
It looks like you're trying to use TypeScript but do not have the required package(s) installed.
Please install typescript by running:
npm install --save-dev typescript
If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).
For eslint, it also throws similar error stating something like:
Please install eslint by running:
npm install --save-dev eslint
Tried multiple solutions which includes:
Turning off typescript and lint while build by: ignoreBuildErrors: true in next.config.js
Adding these packages before build by adding prebuild: npm i typescript in package.json
Removing node_modules and package-lock.json, reinstalling all packages and updating package-lock.json .
Project is no fancy - just a next.js app with environmental variables in Vercel config.
Current Behaviour: Throwing build error mentioned above
Expected Behaviour: Should build successfully
Did you install typescript and eslint? Seems like you might have some packages installed locally that aren’t included in the package.json. Can you share the dependencies list from that file?
Just overridden the installation of packages - npm i --legacy-peer-deps for resolution of packages in legacy way. We are planning to fix conflicting packages later.
@amyegan
After building locally by vercel build and tweaking everything. I figured out.
I had a NODE_ENV='production' in environments variables. I removed it and it worked.
Not sure why this is happening. I think we should create an issue for that.