Getting error while deploying a NextJS project hosted on the GitLab account

Current versus Expected behavior

When deploying my project on Vercel, I encounter the following error during the installation of dependencies:

Installing dependencies...
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error   https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /vercel/.npm/_logs/2024-09-30T08_20_03_052Z-debug-0.log
Warning: Could not identify Next.js version, ensure it is defined as a project dependency.
Error: No Next.js version could be detected in your project. Make sure "next" is installed in "dependencies" or "devDependencies"

Even though the package.json file contains “next” in the dependencies.

I tried clearing cached and npm install as well:

npm cache clean --force && npm install

when I do vercel build locally, it creates the .vercel folder successfully. And vercel --prebuilt works as well, it deploys the prebuild code to deployment URL.
Only when I run the deployment on the Vercel dashboard, it’s failing.

Expected Behavior: The deployment should complete successfully without any errors, and the Next.js version should be detected correctly.

My root directory is also empty as it should be.

Code, configuration, and steps that reproduce this issue

Project information

Deployment URL:
Environment (local, preview, production): production
Project Framework:  Next.js
Build Settings:
  Framework Preset:  Next.js
  Build Command (if not default):
  Output Directory (if not default):
  Install Command (if not default):
Node/Runtime Version: 20
Package Manager: npm
Relevant Packages: next

are you able to run npm run build && npm start locally?

1 Like

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