Skip to content

Commit 84bf1cc

Browse files
committed
Fix default npm prefix for Homebrew installations
Fixes #17
1 parent 1d74209 commit 84bf1cc

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ const getDefaultNpmPrefix = () => {
4444
return APPDATA ? path.join(APPDATA, 'npm') : path.dirname(process.execPath);
4545
}
4646

47+
// Homebrew: `/opt/homebrew/Cellar/node/21.0.0/bin/node` → `/opt/homebrew`
48+
if (process.execPath.includes('/Cellar/node')) {
49+
return process.execPath.slice(0, process.execPath.indexOf('/Cellar/node'));
50+
}
51+
4752
// `/usr/local/bin/node` → `prefix=/usr/local`
4853
return path.dirname(path.dirname(process.execPath));
4954
};

0 commit comments

Comments
 (0)