The following is my project structure
Base Application
|
|----Node Module 1
| |
| |----Node Module 2
|
|----Node Module 2
All these are private repositories. I added the following in the base application's package.json
{
name: "Base Application",
dependencies: {
..
node-module1: "git+https://github.com/abc/node-module1.git",
node-module2: "git+https://github.com/abc/node-module2.git",
..
}
}
I cloned my repository using HTTPS
version (https://github.com/abc/base-application.git) which prompts me for username and password. Once cloned, when I tried to do a npm install
, I was getting the following error
npm ERR! Cloning into bare repository '/home/ubuntu/.npm/_git-remotes/git-https-github-com-abc-node-module1-git-3bd17fdf3s45ae0sdfadf68sdegk72e3'...
npm ERR! remote: Invalid username or password.
npm ERR! fatal: Authentication failed for 'https://github.com/abc/node-module1.git/'
After some digging, I modified my package.json
to include version as suggested here.
{
name: "Base Application",
dependencies: {
..
node-module1: "git+https://github.com/abc/node-module1.git#v0.0.1",
node-module2: "git+https://github.com/abc/node-module2.git#v0.0.1",
..
}
}
This works. But the problem is I am been prompted for the username and password multiple times. This will also create the complexity of creating a version in the node-modules every time a minute change is made.
So how can I use private node modules as how we use public ones.