Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot npm install from bitbucket repo

I'm trying to install a private package recently moved from github to bitbucket.

npm install [email protected]:owner/repo.git

ends up with

npm http GET https://registry.npmjs.org/git

(note package in the url) with this error:

npm ERR! notarget No compatible version found: git@'bitbucket.org:flyvictor/fortune-secruity.git'

(note a ' just after @)

I tried to escape @, wrap repo name in quotes, but always get same result.

For github we use urls formatted as git://github.com/owner/repo#v.v.v and this works fine! But if I use same syntax for bitbucket npm just hangs doing nothing.

Any idea?

p.s. keys, access right and so one are correct. I can contribute to these repos, clone them with git, but not to npm install. Github packages that get installed well are also private.

like image 380
Eugene Kostrikov Avatar asked Jul 28 '14 06:07

Eugene Kostrikov


People also ask

Why is npm not installing?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

How do I force an NPM package to install?

The -f or --force argument will force npm to fetch remote resources even if a local copy exists on disk. The -g or --global argument will cause npm to install the package globally rather than locally.


3 Answers

npm install git+ssh://[email protected]/{user}/{repository}.git
like image 173
user1610694 Avatar answered Oct 25 '22 15:10

user1610694


npm install bitbucket:<bitbucketname>/<bitbucketrepo>
like image 38
gztomas Avatar answered Oct 25 '22 14:10

gztomas


Declaimer: As Eric Uldall said: this method is easy but it lacks security. You have now committed a password in plain text to your repository. That's how is working out lately for me, but not recommended.


Straight from the npm Documentation for the install command:

$ npm install bitbucket:<bitbucketname>/<bitbucketrepo>[#<commit-ish>]

Example:

$ npm install bitbucket:mybitbucketuser/myproject

The Yarn documentation for add as of today Feb 28, 2019 doesn't have support for git repositories.

The above example didn't work for me with private repositories, because you will need to generate a token to use it. How is that?

Login to your Bitbucket account and under user settings add an app password:

img

Then you can add the dependency to your package.json as:

"dependencies": {
    "module": "git+https://<username>:<app-password>@bitbucket.org/<owner>/<repo>.git"
}

or on your terminal type:

npm install git+https://<username>:<app-password>@bitbucket.org/<repo-owner>/<repo>.git

Don't forget to replace:

  • username: with your username
  • password: with your app password
  • repo-owner: with the owner of the repo
  • repo: with the repository name of the module
like image 6
abranhe Avatar answered Oct 25 '22 13:10

abranhe