NPM private git module on Heroku

后端 未结 10 1135
不知归路
不知归路 2020-12-07 13:05

I am trying to deploy my app to Heroku however I rely on using some private git repos as modules. I do this for code reuse between projects, e.g. I have a custom logger I us

10条回答
  •  情书的邮戳
    2020-12-07 14:08

    Basic auth

    GitHub has support for basic auth:

    "dependencies" : {
        "my-module" : "git+https://my_username:my_password@github.com/my_github_account/my_repo.git"
    }
    

    As does BitBucket:

    "dependencies" : {
        "my-module": "git+https://my_username:my_password@bitbucket.org/my_bitbucket_account/my_repo.git"
    }
    

    But having plain passwords in your package.json is probably not desired.

    Personal access tokens (GitHub)

    To make this answer more up-to-date, I would now suggest using a personal access token on GitHub instead of username/password combo.

    You should now use:

    "dependencies" : {
        "my-module" : "git+https://:@github.com/my_github_account/my_repo.git"
    }
    

    For Github you can generate a new token here:

    https://github.com/settings/tokens

    App passwords (Bitbucket)

    App passwords are primarily intended as a way to provide compatibility with apps that don't support two-factor authentication, and you can use them for this purpose as well. First, create an app password, then specify your dependency like this:

    "dependencies" : {
        "my-module": "git+https://:@bitbucket.org/my_bitbucket_account/my_repo.git"
    }
    

    [Deprecated] API key for teams (Bitbucket)

    For BitBucket you can generate an API Key on the Manage Team page and then use this URL:

    "dependencies" : {
        "my-module" : "git+https://:@bitbucket.org/team_name/repo_name.git"
    }
    

提交回复
热议问题