Home Web Front-end JS Tutorial ERR_PNPM_BAD_PM_VERSION This project is configured to use vX of pnpm. Your current pnpm is vY

ERR_PNPM_BAD_PM_VERSION This project is configured to use vX of pnpm. Your current pnpm is vY

Aug 19, 2024 pm 05:08 PM

ERR_PNPM_BAD_PM_VERSION This project is configured to use vX of pnpm. Your current pnpm is vY

The problem

If you started using corepack to manage versions of your package manager you might have bumped into a very curious case of two very similar commands returning different results:

# Calling `pnpm` directly, this works perfectly fine:
> pnpm install
Lockfile is up to date, resolution step is skipped
Already up to date
Done in 1.5s

# Calling `pnpm` through `ember-cli`, this one fails:
> ember install ember-leaflet
?  Installing packages... This might take a couple of minutes.
Command failed with exit code 1: pnpm add --save-dev ember-leaflet
 ERR_PNPM_BAD_PM_VERSION  
This project is configured to use v9.7.0 of pnpm.
Your current pnpm is v9.1.2
Copy after login

You might have tried (like me) to "fix the project" by running:

> corepack prepare pnpm@9.7.0 --activate
> corepack use pnpm@9.7.0
> corepack install --global pnpm@9.7.0
Copy after login

But the result would be still the same.

The analysis

What is the issue here? Why do we have enforced v9.7.0 everywhere, but ember command uses v9.1.2 somehow?

If you run version check from within your project you will, indeed, get the correct version:

> cd ~/my-project
> pnpm --version
9.7.0
Copy after login

But if you run the same command from somewhere else (your home) directory, you will get the "wrong" version:

> cd ~
> pnpm --version
9.1.2
Copy after login

Which is a clue. Now let's take a look at where did the ember in your ember install ember-leaflet command came from:

> cd ~/my-project
> which ember
/Users/michal/Library/pnpm/ember
Copy after login

Aha! So it's my global ember-cli installation and not the project one (which lives in ~/my-project/node_modules/ember-cli/bin/ember).

Solution

Local

If you want to use in project installed version of ember-cli, you can do so by executing the ember command via pnpm exec:

> pnpm exec ember install ember-leaflet
Copy after login

Global

Or you can pin the global version of pnpm to the version matching your project:

> corepack install --global pnpm@9.7.0
> pnpm --version
9.7.0
> cd ~/my-project
> ember install ember-leaflet
?  Installing packages... This might take a couple of minutes.
pnpm: Installed leaflet@^1.9.3
Installed addon package.
Copy after login

pnpm managed by corepack

If you want to solve the global version mismatch, you might bump into an issue where pnpm was installed from different sources than corepack and changing the version within corepack would not influence what version is executed as the other installation would take precedence.

I don't have a straightforward solution for this as it heavily depends on your situation and what setup you want to run, but if you (like me) want to just keep using corepack for managing your pnpm versions you might try following:

  1. brew uninstall pnpm
  2. npm uninstall pnpm -g
  3. Follow the uninstalling pnpm docs
  4. Remove any references of PNPM_HOME from your shell config (~/.zshrc)
  5. Reload your shell config (~/.zshrc)
  6. corepack install --global pnpm@9.7.0
  7. Check what version is now globally available by running in your home directory: pnpm --version

Home directory shenanigans

It might happen that when you're in your home directory pnpm --version command still shows some other version than your global one. Why is that? Well corepack uses packageManager field in your package.json to determine if it should use local version instead of the global one. And it might be that your home directory contains package.json file and thus it looks like a project folder. Simply remove this file, you very likely created it by accident and don't want package.json in ~ directory.


Illustration made by ChatGPT v4o using prompt: "Confused hamster looking at spaghetti of source code, trying to make sense of it --ar 16:9"

The above is the detailed content of ERR_PNPM_BAD_PM_VERSION This project is configured to use vX of pnpm. Your current pnpm is vY. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Replace String Characters in JavaScript Replace String Characters in JavaScript Mar 11, 2025 am 12:07 AM

Replace String Characters in JavaScript

Custom Google Search API Setup Tutorial Custom Google Search API Setup Tutorial Mar 04, 2025 am 01:06 AM

Custom Google Search API Setup Tutorial

Example Colors JSON File Example Colors JSON File Mar 03, 2025 am 12:35 AM

Example Colors JSON File

8 Stunning jQuery Page Layout Plugins 8 Stunning jQuery Page Layout Plugins Mar 06, 2025 am 12:48 AM

8 Stunning jQuery Page Layout Plugins

Build Your Own AJAX Web Applications Build Your Own AJAX Web Applications Mar 09, 2025 am 12:11 AM

Build Your Own AJAX Web Applications

What is 'this' in JavaScript? What is 'this' in JavaScript? Mar 04, 2025 am 01:15 AM

What is 'this' in JavaScript?

Improve Your jQuery Knowledge with the Source Viewer Improve Your jQuery Knowledge with the Source Viewer Mar 05, 2025 am 12:54 AM

Improve Your jQuery Knowledge with the Source Viewer

10 Mobile Cheat Sheets for Mobile Development 10 Mobile Cheat Sheets for Mobile Development Mar 05, 2025 am 12:43 AM

10 Mobile Cheat Sheets for Mobile Development

See all articles