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 Install does not work #1

Open
sanathkr opened this issue Aug 23, 2017 · 4 comments
Open

Yarn Install does not work #1

sanathkr opened this issue Aug 23, 2017 · 4 comments

Comments

@sanathkr
Copy link
Owner

See aws/aws-sam-cli#87. Need to detect if the installation is coming from Yarn and find the binary path without using npm bin

@mhart
Copy link

mhart commented Aug 23, 2017

I just checked and phantomjs-prebuilt seems to work with both npm and yarn –
I wonder if it's worth looking into how they do it: https://github.com/Medium/phantomjs ?

@sanathkr
Copy link
Owner Author

Interesting. Their installer seems to place the binary within node_modules/phantomjs/lib/phantomjs and have package.json's main property point to phantomjs.js file. Upon running the exec the binary.

In my case, I want the binary to be directly placed under bin directory. That's where the difficulty is.

I need to dig deeper into Yarn to figure out how they handle ./bin directories

@mhart
Copy link

mhart commented Aug 23, 2017

Yeah, they just use a more standard method of distributing npm binaries, using the bin property:

https://github.com/Medium/phantomjs/blob/master/package.json#L34-L36

Which links to a shim that executes the "real" binary:

https://github.com/Medium/phantomjs/blob/master/bin/phantomjs

@sanathkr
Copy link
Owner Author

The problem with bin directory is, npm requires binaries to be present in bin directory before running postinstall script. I can't use preinstall because go-npm is downloaded as a dependency only after preinstall script runs.

For best compatibility, I should probably follow phantomjs' approach - Have a JS shim placed under bin directory which will exec the go binary. But honestly I don't like this additional layer of indirection.

Need a bit more digging to find the right middleground

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

Successfully merging a pull request may close this issue.

2 participants