Yarn package manager: install dependencies from private Bitbucket repository
Asked Answered
F

3

15

I'm trying to migrate a project from NPM to Yarn.

Part of my node dependencies are private packages hosted on Bitbucket (not published on NPM registry) under the namespace of the company I'm working for.

With NPM I'm able to declare those kind of dependencies with different syntaxes in my package.json. Like this:

// package.json

"dependencies": {
  ...
  @myCompany/package-name": "bitbucket:bitbucket-username/repo-name.git",
  ...
}

But when I run yarn install I the following error:

ssh: Could not resolve hostname bitbucket: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

I'm running yarn v0.23.3 on a MAC OSX.

Is there any further syntax or workaround to let yarn install private repository from bitbucket?

I've scraped into Yarn's github issues, but I wasn't able to find any hint to decide whether keep on trying or give up.

Thank in advance!

Folderol answered 30/4, 2017 at 15:49 Comment(0)
M
19

Try

"@myCompany/package-name": "git+ssh://[email protected]/bitbucket-username/repo-name.git",

At least, that's what I'm using and it works without any problems.

Metallo answered 4/5, 2017 at 9:58 Comment(1)
It works and accepts a reference to a specific tag/commit, too.Folderol
K
2

I didn't succeeded to know if this issue with yarn was resolved yet. So instead here is a workaround : https://www.npmjs.com/package/yarn-git-install

Kella answered 30/4, 2017 at 15:58 Comment(1)
Thanks for the tip! I'll give it a try with the package you suggested.Folderol
T
0

As @Creynders mentioned, the correct style is:

"@myCompany/package-name": "git+ssh://[email protected]/bitbucket-username/repo-name.git",

For a long time I had been using the style:

"@myCompany/package-name": "git+ssh://[email protected]:bitbucket-username/repo-name.git",

You should use a / not a : after bitbucket.org!

My style worked fine in Yarn, but recently I started receiving the following deprecation warning:

DeprecationWarning: The URL is invalid. Future versions of Node.js will throw an error.

Changing the : to a / fixed the deprecation warning.

Telepathy answered 31/7 at 16:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.