Halo,
On my windows machine, yarn global bin is not equal to npm bin -g
Thanks.
@nueko could you please provide additional information?
Unable to reproduce. Please provide more configuration information.
For example, what versions on NPM and Yarn? How did you install Node/NPM? How did you install Yarn?
On Windows 10:
> npm bin -g
C:\Program Files (x86)\Nodist\bin
> yarn global bin
C:\Program Files (x86)\Nodist\bin
> npm --version
3.9.5
> yarn --version
0.23.2
On OSX:
$ npm bin -g
/Users/me/.nvm/versions/node/v6.3.0/bin
$ yarn global bin
/Users/me/.nvm/versions/node/v6.3.0/bin
$ npm --version
3.10.3
$ yarn --version
0.23.3
@rally25rs @voxsim
macOS 10.12.4
$ node -v
v7.9.0
$ npm --version
4.2.0
$ yarn --version
0.23.4
$ npm bin -g
/usr/local/bin
$ yarn global bin
/usr/local/Cellar/node/7.9.0/bin
Ah so you have Yarn installed with Homebrew. I think this is possibly related to: #3078 and #3255 and #3142 and #1040
It looks like the brew-installed node has it's global bin mapped to /usr/local/bin but Yarn doesn't pick that up when setting its own bin.
yarn global bin # /usr/local/Cellar/node/7.9.0/bin
yarn config set prefix /usr/local/
yarn global bin # /usr/local/bin
Here is the code that gets the "prefix":
function getGlobalPrefix(config: Config, flags: Object): string {
if (flags.prefix) {
return flags.prefix;
} else if (config.getOption('prefix')) {
return String(config.getOption('prefix'));
} else if (process.env.PREFIX) {
return process.env.PREFIX;
} else if (process.platform === 'win32') {
if (process.env.LOCALAPPDATA) {
return path.join(process.env.LOCALAPPDATA, 'Yarn', 'bin');
}
// c:\node\node.exe --> prefix=c:\node\
return path.dirname(process.execPath);
} else {
// /usr/local/bin/node --> prefix=/usr/local
let prefix = path.dirname(path.dirname(process.execPath));
// destdir only is respected on Unix
if (process.env.DESTDIR) {
prefix = path.join(process.env.DESTDIR, prefix);
}
return prefix;
}
}
So it looks like you can set the config option as I mention above, or set a PREFIX env variable.
Otherwise it looks like it falls back to the install path that node executes from which would explain why yours points to a homebrew install directory.
Question for the Yarn core team; Is there a reason Yarn doesn't just execute npm config get prefix and use the output?
this fixed on 0.23.4 and yarn config set prefix $(npm config get prefix)
on 0.23.3, yarn config set prefix $(npm config get prefix) didn't fix the issue.
Most helpful comment
this fixed on 0.23.4 and
yarn config set prefix $(npm config get prefix)on 0.23.3,
yarn config set prefix $(npm config get prefix)didn't fix the issue.