5

For starters, my question is not same as Install npm module from gitlab private repository

We maintain our own npm modules, each in its own sub-folder and together compose a repo, say my_node_modules.git, so is it possible to install a single npm module from it, i.e. is there a command/tool I can use to

npm i -S git+ssh://git@mydomain/path/my_node_modules.git/A_module/
npm i -S git+ssh://git@mydomain/path/my_node_modules.git/B_module/

If not what other solution I have to install that individual private module ?

---- update ----

After doing some research I found I am not alone here.
So npm is against it, https://github.com/npm/npm/issues/2974
yarn is considering it, https://github.com/yarnpkg/yarn/issues/4725

I really don't like the idea here npm install package from github repo subfolder, the postinstall sript

I am thinking about using git subtree. I leave my question here to see if someone can come up some ideas.

Qiulang
  • 10,295
  • 11
  • 80
  • 129
  • 1
    I also need this approach. Have you found the solution? – Bhojendra Rauniyar Mar 30 '19 at 08:15
  • 1
    I did find a solution for that. https://www.npmjs.com/package/git-directory-deploy – Qiulang Mar 30 '19 at 13:12
  • @Qiulang can you provide some guide on how `git-directory-deploy` works to you? I also need to install a package which belongs to a private mono-repo on GitHub. `GitPkg` works for sub-folder packages but it doesn't support private repo. Thanks. – Wayne Mao Jun 05 '23 at 04:30
  • This is a rather old question I need to take some time to think about my then solution again. – Qiulang Jun 05 '23 at 05:28

1 Answers1

0

It's really not that hard to just publish your package into gitlab registry. It can obviously be done from .gitlab-ci.yml no matter how nested your module is. See gitlab guide for more details.

git-directory-deploy is not the right tool for this job and any other approach(like https://gitpkg.now.sh/) will add a level of indirection anyway.

yuranos
  • 8,799
  • 9
  • 56
  • 65