Hello everybody, how can i instruct gradle to get ...
# javascript
j
Hello everybody, how can i instruct gradle to get a npm dependency directly from a github repo instead of npmjs.com?
e
That would have to pass through yarn or npm. Do yarn or npm allow doing that?
j
npm does, i would assume yarn does too, but i dont know for sure
e
Try using the
package@<git remote url>
notation instead of the npm package name.
Example from SO:
Copy code
fancybox@https://github.com/fancyapps/fancybox
j
No, that won't work
e
Have a you got an example of a repo I can try out?
j
Any repo with a package from npm with a package.json in its root should work, eg. https://github.com/websockets/ws for npm its as simple as using
npm i websockets/ws
which will pull it from github. However, the gradle plugin always attaches a @x.x.x which makes things fail. I am looking around in the kotlin repo, to find the responsible code ... thought takes me a while ...
e
Here you go:
Copy code
implementation(npm("ws", "<https://github.com/websockets/ws>"))
A bit of a hack, but it works under Yarn : )
j
Cool, thanks a lot!