Next.js 14 build throws typescript error on vercel

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

I would appreciate a solution.

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?

Yes,
I have it in dev dependencies:

"devDependencies": {
    "@babel/core": "^7.22.9",
    "@babel/eslint-parser": "^7.22.9",
    "@types/downloadjs": "^1.4.6",
    "@types/react-image-fallback": "^8.0.6",
    "@types/xlsx": "^0.0.36",
    "eslint": "^8.46.0",
    "eslint-config-next": "^13.4.12",
    "eslint-config-prettier": "^8.10.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-import-resolver-typescript": "^3.5.5",
    "eslint-plugin-import": "^2.28.0",
    "eslint-plugin-unused-imports": "^3.0.0",
    "next-transpile-modules": "^10.0.1",
    "node-gyp": "10.1.0",
    "prettier": "^3.0.1",
    "sass": "^1.85.1",
    "typescript": "^5.3.3"
  }

What are the build and development settings? Any overrides?

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.

And using node 20.x.

@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.

Thanks a lot for the help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.