pnpm install -global doesn't create symlink to /usr/local/bin

Created on 4 Sep 2018  Β·  31Comments  Β·  Source: pnpm/pnpm

pnpm version:

2.15.0

Code to reproduce the issue:

waylandchan@bctmac ~/sandbox/orderbook$ which tsc
tsc not found
waylandchan@bctmac ~/sandbox/orderbook$ pnpm install -g typescript
Packages: +1
+
Resolving: total 1, reused 1, downloaded 0, done

/usr/local/Cellar/node/10.9.0/pnpm-global/1:

    typescript 3.0.3

waylandchan@bctmac ~/sandbox/orderbook$ which tsc
tsc not found
waylandchan@bctmac ~/sandbox/orderbook$ pnpm --version
2.15.0
waylandchan@bctmac$ ~/sandbox/orderbook$ node --version
v10.9.0
waylandchan@bctmac$ ~/sandbox/orderbook$ npm bin -g
/usr/local/bin
waylandchan@bctmac$ ~/sandbox/orderbook$ pnpm bin -g
/usr/local/bin
waylandchan@bctmac$ ~/sandbox/orderbook$ ls -al /usr/local/Cellar/node/10.9.0/bin/tsc
-rwxr-xr-x 1 waylandchan staff 2857 Sep 4 18:55 /usr/local/Cellar/node/10.9.0/bin/tsc
waylandchan@bctmac$ ~/sandbox/orderbook$ date
Tue Sep 4 18:56:06 HKT 2018

Expected behavior:

I expect the 'tsc' binary to be installed and present on my current path, which it isn't. My guess is that there should be a symlink from /usr/local/Cellar/node/10.9.0/bin/tsc => /usr/local/bin/tsc

Actual behavior:

The pnpm i -g typescript only gets installed to /usr/local/Cellar/node/10.9.0/bin

Additional information:

This bug was first reported in Issue 695

  • node -v prints: v10.9.0
    OSX High Sierra 10.13.5
globally installed packages help wanted macOS 2 bug

Most helpful comment

The latest version of pnpm should have fixes for all these issues.

All 31 comments

Hey @zkochan
Don't work in 2.15.3 either, I tried same couple of months ago and it was not working even then. So I moved back to npm.

OSX High Sierra 10.13.6

I don't know if it's the same issue, but --global isn't working correctly on Windows either. Packages are being installed to APPDATA even if prefix is set:

> npm bin -g
C:\Users\mrkishi\scoop\persist\nodejs\bin

> pnpm bin -g
C:\Users\mrkishi\scoop\persist\nodejs\bin

> npm config get prefix -g
C:\Users\mrkishi\scoop\persist\nodejs\bin

> pnpm config get prefix -g
C:\Users\mrkishi\scoop\persist\nodejs\bin

> pnpm i -g rimraf
Packages: +12
++++++++++++
Resolving: total 12, reused 0, downloaded 12, done

C:\Users\mrkishi\AppData\Roaming\npm\pnpm-global\1:
+ rimraf 2.6.2

you can set pnpm-prefix (it was added in this PR https://github.com/pnpm/pnpm/pull/1334)

Hi, @zkochan, thank you for the quick reply! I must be missing something -- according to the docs pnpm uses npm configuration, yet I can't get pnpm-prefix to work either.

> pnpm --version
2.16.1

> npm config get -g pnpm-prefix
C:\Users\mrkishi\scoop\persist\nodejs\bin

> pnpm config get -g pnpm-prefix
C:\Users\mrkishi\scoop\persist\nodejs\bin

> pnpm i -g rimraf
Already up-to-date
Resolving: total 12, reused 12, downloaded 0, done

C:\Users\mrkishi\AppData\Roaming\npm\pnpm-global\1:
+ rimraf 2.6.2

Should I be using something other than pnpm config set -g pnpm-prefix 'path'?

@ExE-Boss did pnpm-prefix solve the issue in your case?

@zkochan pnpm doesn't seem to be getting the right prefix for some reason.

> pnpm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.4.1 node/v10.10.0 win32 x64"

; userconfig C:\Users\mrkishi\.npmrc
access = "public"

; globalconfig C:\Users\mrkishi\scoop\persist\nodejs\bin\etc\npmrc
access = "public"
pnpm-prefix = "C:\\Users\\mrkishi\\scoop\\persist\\nodejs\\bin"
prefix = "C:\\Users\\mrkishi\\scoop\\persist\\nodejs\\bin"
; ^NOTE: I tried both with and without `prefix` set as a global

; builtin config undefined
cache = "C:\\Users\\mrkishi\\scoop\\persist\\nodejs\\cache"
prefix = "C:\\Users\\mrkishi\\scoop\\persist\\nodejs\\bin"

; node bin location = C:\Users\mrkishi\scoop\apps\nodejs\current\node.exe
; cwd = D:\Projects\REDACTED
; HOME = C:\Users\mrkishi
; "npm config ls -l" to show all defaults.
console.log(conf.get('prefix'))
// C:\Users\mrkishi\scoop\apps\nodejs\current

@mrkishi What version of pnpm are you using?

@ExE-Boss I just installed it:

> npm i -g pnpm
C:\Users\mrkishi\scoop\persist\nodejs\bin\pnpm -> C:\Users\mrkishi\scoop\persist\nodejs\bin\node_modules\pnpm\lib\bin\pnpm.js
C:\Users\mrkishi\scoop\persist\nodejs\bin\pnpx -> C:\Users\mrkishi\scoop\persist\nodejs\bin\node_modules\pnpm\lib\bin\pnpx.js
+ [email protected]

> pnpm --version
2.16.1

same issue here

For windows, it seems pnpm installed packages in %userprofile%\.pnpm-store\2\registry.npmjs.org but install command want to find them in %appdata%\npm\pnpm-global\1\node_modules.
And it works in version 2.8.0 but fails after that.

Any updates? I really want to switch to pnpm but the global install issue block me. I first meet this issue one year ago, now one year passed but it seems we haven't make any progress on this.

There's a fix from @SkReD in [email protected].

still seeing this on 3.4.1.

/ ξ‚’
➜ yarn global add pnpm
yarn global v1.13.0
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[#################---------------------------------------------------------------------------------------------------------------------------------------------------------------] 452/462[#[#################################################################################################################--------------------------------------------------------------] 2994/4[###[4/4] πŸ”¨  Building fresh packages...

success Installed "[email protected]" with binaries:
      - pnpm
      - pnpx
✨  Done in 4.63s.

/ ξ‚’ took 5s
➜ pnpm install -g jira-cl
 WARN  jira-cl > request-promise: [email protected] requires a peer of request@^2.34 but none was installed.
 WARN  jira-cl: [email protected] requires a peer of request@^2.34 but none was installed.
Packages: +279
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Resolving: total 279, reused 0, downloaded 279, done
node_modules/.registry.npmjs.org/core-js/2.6.9/node_modules/core-js: Running postinstall script, done in 146ms
node_modules/.registry.npmjs.org/hugo-bin/0.43.6/node_modules/hugo-bin: Running postinstall script, done in 3s

/usr/local/Cellar/node/11.7.0/pnpm-global/2:
+ jira-cl 1.2.1

/ ξ‚’ took 25s
➜ jira
zsh: command not found: jira

/ ξ‚’
➜ which node
/usr/local/bin/node

/ ξ‚’
➜ node -v
v11.7.0
Edit:

Appears this might be an issue with node being installed via brew (though I was sure I hadn't installed via brew, because I knew that could cause issues). Once I used this script, pnpm is able to set it globally

I still can't use pnpm to install globally either on Win10. I am using node installed via nvm, so directories are wonky, but nvm -g works fine.....

@tomByrer I just revisited this issue and it's indeed still a problem when you have non-default prefix/bin paths. _However_, pnpm-prefix is respected now, so you can use that instead!

@zkochan: I got some info on a clean Windows 10 installation. Hopefully this helps:

> node --version
v12.4.0

> npm --version
6.9.0

> pnpm --version
3.4.1

> pnpm config --global get prefix
C:\Users\mrkishi\scoop\persist\nodejs\bin

If I do pnpm install -g rimraf and log the values right at this line: https://github.com/pnpm/pnpm/blob/ac684d0e14c5377351d6cd175e369b4ed540f6c2/packages/config/src/index.ts#L164

I get these:

{
  'pnpmConfig.rawNpmConfig.prefix': 'C:\\Users\\mrkishi\\scoop\\persist\\nodejs\\bin',
  'npmConfig.prefix': 'C:\\Users\\mrkishi\\scoop\\persist\\nodejs\\bin',
  'npmConfig.globalBin': undefined,
  'npmConfig.globalPrefix': 'C:\\Users\\mrkishi\\scoop\\persist\\nodejs\\bin',
  npmGlobalPrefix: 'C:\\Users\\mrkishi\\AppData\\Roaming\\npm',
  globalBin: 'C:\\Users\\mrkishi\\AppData\\Roaming\\npm',
  globalPrefix: 'C:\\Users\\mrkishi\\AppData\\Roaming\\npm\\pnpm-global'
}

So findBestGlobalPrefixOnWindows isn't respecting prefix if it's outside appdata and instead just appending npm to it: https://github.com/pnpm/pnpm/blob/ac684d0e14c5377351d6cd175e369b4ed540f6c2/packages/config/src/findBestGlobalPrefixOnWindows.ts#L4-L16

Previously, the issue was that it was ignoring prefix entirely, which was introduced here: https://github.com/pnpm/pnpm/commit/612e661465a8c60c5690023deb12e729d9f17237.

I don't know why they were having problems, though, since when you install node to with the default installer to c:\program files, npm will have a prefix=${APPDATA}\npm out of the box on npmrc. Maybe npm-conf wasn't returning the right globalPrefix back then?

First time trying pnpm (v3.6.0) on OSX and have this issue.

npm config get prefix
/usr/local

pnpm config get pnpm-prefix
undefined

...so I ran pnpm config set pnpm-prefix /usr/local as suggested above but it's still not symlinking globally installed packages for me.

Should I be using a non-default prefix like something in my home directory?

First time trying pnpm (v3.6.0) on OSX and have this issue.

npm config get prefix
/usr/local

pnpm config get pnpm-prefix
undefined

...so I ran pnpm config set pnpm-prefix /usr/local as suggested above but it's still not symlinking globally installed packages for me.

Should I be using a non-default prefix like something in my home directory?

Nevermind, I had been using node/npm installed via homebrew (as mentioned by @snowe2010) and there does indeed seem to be some kind of incompatibility.

Removed everything and installed node via the official installer and it is working great now πŸ‘

I tried today (Windows10) with v4.12.4 and:
install -g still ignores pnpm-prefix set both in npm's builtin config and npm's global config, setting it into user config worked. Note that it all show perfectly fine in "config list".

C:\Users\Michal>pnpm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.4 node/v12.16.1 win32 x64"

; userconfig C:\Users\Michal\.npmrc
pnpm-prefix = "C:\\Users\\Michal\\AppData\\Local\\npm"

; globalconfig C:\Users\Michal\AppData\Local\npm\etc\npmrc
pnpm-prefix = "C:\\Users\\Michal\\AppData\\Local\\npm"

; builtin config undefined
cache = "C:\\Users\\Michal\\AppData\\Local\\npm-cache"
pnpm-prefix = "C:\\Users\\Michal\\AppData\\Local\\npm"
prefix = "C:\\Users\\Michal\\AppData\\Local\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\Michal
; HOME = C:\Users\Michal
; "npm config ls -l" to show all defaults.

Note that my npm is also installed in "prefix" location, so the built-in config is located at
C:\Users\Michal\AppData\Local\npm\node_modules\npm\npmrc

Also I had to dig reallly long to find about pnpm-prefix it definitely should be added into the docs, i guess here (?):
https://pnpm.js.org/en/configuring

I'm installing pnpm for the first time and encountering this issue. The recommended install command npx pnpm add -g pnpm fails to symlink pnpm. My Node is installed via homebrew.

So I've perused ~5 issues, I don't really understand what's going on, but I'm experiencing this:

$ pnpm -v
4.13.0

$ npm config get prefix
/usr/local
$ pnpm config get pnpm-prefix
undefined

$ npm bin -g
/usr/local/bin
$ pnpm bin -g
/usr/local/bin

$ vue -V
@vue/cli 4.3.0

$ pnpm install -g @vue/cli
Packages: +1048
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Resolving: total 1051, reused 1051, downloaded 0, done
node_modules/.pnpm/registry.npmjs.org/ejs/2.7.4/node_modules/ejs: Running postinstall script, done in 148ms
node_modules/.pnpm/registry.npmjs.org/core-js/3.6.5/node_modules/core-js: Running postinstall script, done in 146ms
node_modules/.pnpm/registry.npmjs.org/core-js/2.6.11/node_modules/core-js: Running postinstall script, done in 139ms
node_modules/.pnpm/registry.npmjs.org/@apollo/protobufjs/1.0.3/node_modules/@apollo/protobufjs: Running postinstall script, done in 203ms
node_modules/.pnpm/registry.npmjs.org/fsevents/1.2.12/node_modules/fsevents: Running install script, done in 3s
node_modules/.pnpm/registry.npmjs.org/nodemon/1.19.4/node_modules/nodemon: Running postinstall script, done in 351ms

/usr/local/Cellar/node/13.12.0/pnpm-global/3:
+ @vue/cli 4.3.1

$ vue -V
@vue/cli 4.3.0

Hopefully that helps.

Maybe it would be helpful to summarize in the documentation:

Global installs are currently [broken.] (or similar) Please track #1360 for information.

Also ran into this issue. Coming back to pnpm after briefly trialing it a few years ago when it was fresh and understandably rough around the edges… disappointing to see some aspects still don't work properly.

Nevermind, I had been using node/npm installed via homebrew (as mentioned by @snowe2010) and there does indeed seem to be some kind of incompatibility.

Maybe this is the real issue here? Either way it needs fixing… Homebrew is by far the best way to install things on macOS.

Any news on this? I'm having the same issue on Arch Linux on WSL2 (so maybe we could remove the OSX tag?). I installed Node through asdf.

@izzues it looks like one of the labels is "help wanted" so the main dev probably can't work on it due to OS restrictions.

why not a default pnpm-prefix="$HOME/.pnpm", then:

$HOME
└── .pnpm
    └── bin
    └── pnpm-global
    └── pnpm-store

We can just export PATH="$PATH":"$HOME/.pnpm/bin" ... (we can also edit the sys env in pnpm postinstall script)

  1. Check npm prefix: npm config get prefix
  2. Chcek pnpm prefix: pnpm config get pnpm-prefix
  3. If pnpm-prefix is undefined, set it to the npm prefix: pnpm config set pnpm-prefix /usr/local
  4. ...
  5. Profit!

Trying to figure out the location of the global npm bins seems to not work well. Setting pnpm-prefix is not very user friendly. Finding the right location for the bins is super hard because there are different OS and toolings.

I think we can try the next solution:

  1. Take the directories from the PATH env variable.
  2. If one of the directories has node, nvm, nvs, npm in the path, take it. If not, write the bin to the first directory to which pnpm has write permission.

I published a fix. You can install it via: npm i -g pnpm@dev.

Let me know if it solves some of the issues.

There are too many different issues in this issue. I think I have fixed probably most of them in pnpm v5.2.4.

It should work with no additional configuration (so no need to use pnpm-prefix).

If anyone does face issues, file a new issue with information about pnpm, node version, OS and any additional toolings like nvs, nvm.

ok, seems like my solution has an issue on Windows. See #2649

I'll fix that in the next version

The latest version of pnpm should have fixes for all these issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seoker picture seoker  Β·  31Comments

jiripospisil picture jiripospisil  Β·  39Comments

KSXGitHub picture KSXGitHub  Β·  37Comments

quinton-ashley picture quinton-ashley  Β·  27Comments

nickpape picture nickpape  Β·  37Comments