Andrea Carraro
Andrea Carraro

Reputation: 10449

Yarn package manager: install dependencies from private Bitbucket repository

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!

Upvotes: 15

Views: 11638

Answers (3)

aardvarkk
aardvarkk

Reputation: 15996

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.

Upvotes: 0

Creynders
Creynders

Reputation: 4583

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.

Upvotes: 19

Kuu Aku
Kuu Aku

Reputation: 320

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

Upvotes: 2

Related Questions