Corepack not detecting packageManager

Hi!

I’m currently trying to convert a Next.js project from using npm to pnpm. Locally on my machine everything works as expected. However, trying to deploy to Vercel, fails.

Vercel is supposed to automatically detect the package manager. It correctly detects that I’m using pnpm v9 or v10 due to the lockfile. It chose v9 due to the age of my project. Weird, but Ok. It recommends to set this environment variable to make use of Corepack and the packageManger field from my package.json.

I did set the environment variable and have the packageManager field set. See: chore: replace npm with pnpm by simonknittel · Pull Request #1254 · simonknittel/sinister-incorporated · GitHub

However, it complains about not detecting that field:

Here you can see all changes in the pull request for that respective preview deployment: chore: replace npm with pnpm by simonknittel · Pull Request #1254 · simonknittel/sinister-incorporated · GitHub

Am I missing something?

Hey, Could you temporarily enable Source code visibility so we can check? Also just to confirm, you have set ENABLE_EXPERIMENTAL_COREPACK in your project Environment, right?

Hey!
Yes, I’ve set that variable:

The setting for Customer Success Code Visibility doesn’t exist for me. I’ve searched all project and team settings. Maybe this doesn’t exist for my Hobby plan?

Bump.
@swarnava Any news?

I cannot reproduce this unfortunately:

Do you have a minimal repository which I can try? I tried building this branch and it seems setting correct PNPM version.

I’ve built this reproduction: GitHub - simonknittel/pnpm-on-vercel-reproduction: Reproduction for https://community.vercel.com/t/corepack-not-detecting-packagemanager/8870 I’ve removed everything except for the pnpm stuff.

The reproduction also runs into the same error:

However, I’ve noticed that there might be an issue with the root directory setting which is causing this error. As you can see in my reproduction and my original repository, the app including pnpm files is in a sub directory called app. I’ve also set the Root Directory setting to that app directory:

When I remove that setting and move all app files into the root directory of the repository, the build succeeds:

After I’ve moved the files back and enabled the setting again, the build broke again.

So, it seems to me that, whatever is trying to detect the packageManger property, does not play nicely with the Root Directory setting.

It looks like Vercel can find the package.json but was unable to detect a package manager defined in the file. The packageManager must be defined in your package.json in order to use corepack with Vercel, please see here.

The packageManager is set, you can see here: pnpm-on-vercel-reproduction/app/package.json at main · simonknittel/pnpm-on-vercel-reproduction · GitHub

Yes.

Then, set the packageManager property in the package.json file in the root of your repository.

If it’s not monorepo, you can ignore Root Directory and deploy whole app like any traditional repo

But the Root directory is needed since the app incl. it’s package.json is located in the subdirectory called app. There is no package.json in the root of the repository.

In that case, have you tried setting packageManager on the root directory’s package.json?

A post was split to a new topic: No Next.js version detected

A post was split to a new topic: Corepack issue