Khusbu Mishra
Khusbu Mishra

Reputation: 181

Add cordova plugin from GitLab private repo

cordova plugin add http://gitlab.com/<user>/<private-repo>.git

I am unable to add a cordova plugin from a private repo in GitLab. When I run the above command it throws me the following error:

Error: Failed to fetch plugin http://gitlab.com/<user>/<private-repo>.git via registry.
    Probably this is either a connection problem, or plugin spec is incorrect.
    Check your connection and plugin name/version/URL.
    Error: npm: Command failed with exit code 1 Error output:
    npm ERR! fetch failed http://gitlab.com/<user>/<private-repo>.git
    npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 401
    npm ERR! fetch failed http://gitlab.com/<user>/<private-repo>.git
    npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 401
    npm ERR! fetch failed http://gitlab.com/<user>/<private-repo>.git
    npm ERR! Darwin 16.7.0
    npm ERR! argv "~/.nvm/versions/node/v6.4.0/bin/node" 
    "~/.nvm/versions/node/v6.4.0/bin/npm" "install" 
    "http://gitlab.com/<user>/<private-repo>.git" "--save"
    npm ERR! node v6.4.0
    npm ERR! npm  v3.10.3

    npm ERR! fetch failed with status code 401
    npm ERR! 
    npm ERR! If you need help, you may report this error at:
    npm ERR!     <https://github.com/npm/npm/issues>

    npm ERR! Please include the following file with any support request:

Note: I am using cordova 7.0.1

I can see that status code is 401. I was accepting a password prompt for fetching from the private repo but unfortunately thats not the case. similar question was asked but I don't want to clone the repo and add via local folder. Any kind of help will be appreciated. Thanks :)

Upvotes: 3

Views: 3762

Answers (3)

geoffreybr
geoffreybr

Reputation: 41

The problem with the --no-fetch work-around is... that the plugin is not fetched.

There are related open issues referenced in Cordova issue tracker for versions 7.x and 8.x:

I found two work-around:

  • clone the repo and add the plugin referring to the local path (see comment in CB-13507)
  • downgrade to Cordova v6.x to add your plugin then rollback to latest version

Upvotes: 3

Ross
Ross

Reputation: 1425

Try the following to add a plugin from a private GitLab repository using the latest version of Cordova.

cordova plugin add git+ssh://[email protected]:<group|user>/<repo>#<branch>

Upvotes: 10

Alfredo Luco G
Alfredo Luco G

Reputation: 974

you need to no-fetch this plugin. So, you need to run that command:

sudo cordova plugin add http://gitlab.com/<user>/<private-repo>.git --save --nofetch

Regards

Upvotes: 1

Related Questions