pnpm: zsh: /opt/homebrew/bin/pnpm: bad interpreter: /opt/homebrew/opt/node/bin/node: no such file or directory

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

9.7.0

Which area(s) of pnpm are affected? (leave empty if unsure)

Operating System (Windows, MacOS, Linux)

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

stop working after an usual

brew update && brew upgrade && brew doctor

Describe the Bug

> pnpm -v
zsh: /opt/homebrew/bin/pnpm: bad interpreter: /opt/homebrew/opt/node/bin/node: no such file or directory

I had to remove pnpm from brew and install it globally using npm.

Expected Behavior

> pnpm -v
9.7.0

Which Node.js version are you using?

v22.5.1

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 30
  • Comments: 22 (3 by maintainers)

Most upvoted comments

By using

brew install --build-from-source pnpm

seems work

My solution was to edit /opt/homebrew/bin/pnpm ie /opt/homebrew/bin/pnpm@ -> ../Cellar/pnpm/9.7.0/bin/pnpm, changing the first line to use node from my path instead of assuming I have node installed via Homebrew. I have nvm installed via Homebrew and node installed via nvm. The unedited version of the first line is shown on the second line, commented out.

#!/usr/bin/env node
// #!/opt/homebrew/opt/node/bin/node
const [major, minor] = process.version.slice(1).split('.')
const COMPATIBILITY_PAGE = `Visit https://r.pnpm.io/comp to see the list of past pnpm versions with respective Node.js version support.`

// We don't use the semver library here because:
//  1. it is already bundled to dist/pnpm.cjs, so we would load it twice
//  2. we want this file to support potentially older Node.js versions than what semver supports
if (major < 18 || major == 18 && minor < 12) {
  console.log(`ERROR: This version of pnpm requires at least Node.js v18.12
The current version of Node.js is ${process.version}
${COMPATIBILITY_PAGE}`)
  process.exit(1)
}

// We need to load v8-compile-cache.js separately in order to have effect
try {
  require('v8-compile-cache');
} catch {
  // We don't have/need to care about v8-compile-cache failed
}

global['pnpm__startedAt'] = Date.now()
require('../dist/pnpm.cjs')

// if you want to debug at your local env, you can use this
// require('../lib/pnpm')

Something clearly broke with pnpm 9.7.0 and nvm-installed node. Everything worked up until yesterday when the new pnpm was updated via homebrew.

Have anyone found a fix yet to this issue. I just updated today, and got the same error.

certainly the issue seems to involve those who use nvm I solved it by uninstalling pnpm with brew and then reinstalling it with

brew install --build-from-source pnpm

is it still broken if you downgrade to pnpm 9.6?

Can’t downgrade to 9.6 using homebrew (can only downgrade to pnpm v8.x, as far as I can tell…correct me if I’m wrong). I would simply like to have it working as it always did with brew-installed node. it was working 2 days ago before upgrading to 9.7

The Homebrew team has looked into this, and this should fix the issue when it’s released: https://github.com/Homebrew/brew/pull/17993

These steps worked for me-

  1. Uninstall the pnpm-

Either with-

npm rm -g pnpm

Or with-

rm -rf $PNPM_HOME
  1. Re-install it using curl (Reference link)
curl -fsSL https://get.pnpm.io/install.sh | sh -

Now, check the pnpm version-

pnpm -v