Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn global add bower --prefix /usr/local should add binary or link in /usr/local/bin #1877

Closed
dev-jpctrade opened this issue Nov 16, 2016 · 16 comments
Assignees
Labels

Comments

@dev-jpctrade
Copy link

Do you want to request a feature or report a bug?

feature

What is the current behavior?
yarn global add bower --prefix /usr/local does nothing in /usr/local/bin folder

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?
Have binary or link in /usr/local/bin

Please mention your node.js, yarn and operating system version.
7.1.0, 0.17.2, debian/8

PS: close if this is a dup, couldn't find exact one.

@vegawong
Copy link

vegawong commented Nov 16, 2016

I have the same problem. I can't find the link in the path which print from 'yarn global bin' after i run 'yarn global add pm2'. How can i resolve it?

my yarn version is 0.17.2
node version is v6.5.0 which install by nvm
system is centos 7

$ yarn global add pm2
# ...

$ yarn global bin 
/root/.nvm/versions/node/v6.5.0/bin

$ yarn config list
yarn config v0.17.2
info yarn config
{ registry: 'https://registry.npm.taobao.org',
  'version-tag-prefix': 'v',
  'version-git-tag': true,
  'version-git-sign': false,
  'version-git-message': 'v%s',
  'init-version': '1.0.0',
  'init-license': 'MIT',
  'save-prefix': '^',
  'ignore-scripts': false,
  'ignore-optional': false,
  'strict-ssl': true,
  'user-agent': 'yarn/0.17.2 npm/? node/v6.5.0 linux x64' }
info npm config
{}

$ find / -name pm2
/root/.config/yarn/global/node_modules/pm2
/root/.config/yarn/global/node_modules/pm2/bin/pm2
/root/.config/yarn/global/node_modules/pm2/lib/templates/pm2
/root/.config/yarn/global/node_modules/pm2/lib/templates/logrotate.d/pm2
/root/.cache/yarn/npm-pm2-2.1.5-7243ed0f9373c649ee3a217cf88aa8c436250359/bin/pm2
/root/.cache/yarn/npm-pm2-2.1.5-7243ed0f9373c649ee3a217cf88aa8c436250359/lib/templates/pm2
/root/.cache/yarn/npm-pm2-2.1.5-7243ed0f9373c649ee3a217cf88aa8c436250359/lib/templates/logrotate.d/pm2

why the global installed package's folader is not int the path '/root/.nvm/versions/node/v6.5.0/lib/node_modules' ?

@vitorgalvao
Copy link

Confirmed on macOS 10.11.6 as well.

@colkito
Copy link

colkito commented Nov 16, 2016

same issue!
macOS sierra 10.12.1, node 7.1.0, yarn 0.17.2
node and yarn installed via brew

@RickyLin
Copy link

Same issue.
Mac OS Sierra 10.12.1, node 7.1.0, yarn 0.17.2
Node and Yarn are installed via brew.

@torifat torifat self-assigned this Nov 16, 2016
@akloeber
Copy link

Confirmed on Ubuntu 14.04.5 LTS, node 4.6.2 LTS, yarn v0.17.2 after installing pm2 globally which logs:

root@vagrant-ubuntu-trusty-64:~# yarn global add pm2
yarn global v0.17.2
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
⠁
⠁
⠁
⠁
error Error running install script for optional dependency: "/usr/local/share/.config/yarn/global/node_modulessuccess Installed [email protected] with binaries:
      - pm2
      - rundev
      - pm2-dev
      - pm2-docker
Done in 8.79s.

No pm2 binary has been linked at /usr/bin/pm2 (yarn global bin returns /usr/bin).

@dev-jpctrade
Copy link
Author

dev-jpctrade commented Nov 17, 2016

looks like it fixed on 0.17.3 with additional parameters, closing

yarn global add bower --prefix /usr/local --global-folder /usr/local/lib/node_modules

@akloeber
Copy link

With yarn v0.17.3 after running
# yarn global add pm2 --prefix /usr/local --global-folder /usr/local/lib/node_modules

linking of binaries into the bin folder seems to be working but a folder /usr/local/lib/node_modules/node_modules gets created with the node modules inside.

This causes additional errors which I suppose are related to this directory structure:

# pm2 version
module.js:327
    throw err;
    ^

Error: Cannot find module 'debug'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/node_modules/pm2/constants.js:2:14)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

Furthermore IMHO installation of global modules via yarn global add without any special requirements should just work on any platform without having to define additional parameters. Otherwise I suppose this will cause trouble for lots of users.

@akloeber
Copy link

When using yarn global add pm2 --prefix /usr/local --global-folder /usr/local instead pm2 is working as expected but the resulting folder structure with having modules directly under /usr/local/node_modules (should be /usr/local/lib/node_modules) and package.json/yarn.lock directly under /usr/local is kind of sub-optimal.

@dev-jpctrade
Copy link
Author

dev-jpctrade commented Nov 17, 2016

ok, reopened, my original post was a feature request, but this become bug report.
I will leave it as yarn devs handle remaining issues and this thread itself.

@dev-jpctrade dev-jpctrade reopened this Nov 17, 2016
@torifat
Copy link
Member

torifat commented Nov 17, 2016

Please open a new issue reporting the --global-folder bug. This is not a --prefix bug.

And, try yarn global add pm2 --prefix /usr/local

your don't need --global-folder /usr/local to install in /usr/local/bin

@torifat torifat closed this as completed Nov 17, 2016
@torifat
Copy link
Member

torifat commented Nov 17, 2016

If anyone else having trouble with --prefix /usr/local then please first remove the package yarn global remove <package>, and then try yarn global add <package> --prefix /usr/local. If it still doesn't work then report, we will reopen this issue.

@nragaz
Copy link

nragaz commented Nov 17, 2016

@torifat I'm still not seeing the correct behaviour after e.g.:

$ yarn global remove bower
$ yarn global add bower --prefix /usr/local
$ bower
-bash: /usr/local/bin/bower: No such file or directory

UPDATE: arg, was still on 0.17.2 -- sorry! 0.17.3 worked correctly

@torifat
Copy link
Member

torifat commented Nov 17, 2016

@nragaz what is your yarn version?

@jonnybarnes
Copy link

For me yarn global add --prefix /usr/local <package> worked, and the binary was sym-linked to /usr/local/bin properly. Does --prefix /usr/local need to be added to yarn global upgrade going forward?

@colkito
Copy link

colkito commented Nov 21, 2016

what is your yarn version and OS? @jonnybarnes

@jonnybarnes
Copy link

yarn v0.17.8 running on Arch Linux. yarn was installed from the AUR: https://aur.archlinux.org/packages/yarn/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants