Monday, 2 September 2019

NPM: How to build a project with git-based dependencies without having to call 'git' command?

I have an NPM project that uses a git dependency

{
  "repository": {
    "type": "git",
    "url": "https://bitbucket.org/my-private-group"
  },
  "dependencies": {
    "my-dependency": "bitbucket:group/lib#version",
  },
}

Now I want to build this project in CI using Docker with node installed.

Problem: node install tries to call git and fails because git is not there. But even if I install git it still requires authentication because it is a private repository.

At the moment I see the following solutions:

  • I would have to install git in docker and add an SSH key to be able to download the source code.
  • I may pack the related repository into the Docker image and use npm link. But this option still requires knowing dependencies set up in package.json which makes it complicated.
  • Setup an own npm repository to post artifact and do not use git dependencies. This option is unfortunately not achievable in my case.

Question: What is the best way of handling git dependencies in CI? Are there any other options a part from the listed options. What is the best practice?



from NPM: How to build a project with git-based dependencies without having to call 'git' command?

No comments:

Post a Comment