简体   繁体   中英

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 :)

尝试以下操作,使用最新版本的Cordova从私有GitLab存储库添加插件。

cordova plugin add git+ssh://git@gitlab.example.com:<group|user>/<repo>#<branch>

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM