Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make my repository a dependency in package.json and have it prompt me for my information?

I want to put my one of my own repositories as a dependency to a project I am working on. Right now I am using NPM link to do that. Also, I'd like it to prompt me for my username and password instead of putting that kind of data in my repository when I use npm install. How do I do that? It doesn't do that now.

I want the content of the repository to show up as their own folder The problem is when I run npm install it gives me a bunch of error messages from NPM. So I've tried two things. First I tried cloning a public repo from github:

Public Repo Github

SO in package.json, I used the ssh like this:

"dependencies": {
  "repo_name": "[email protected]:ownername/reponame.git#84876fa5aasf55fssfsfafsa"

},

^Note that data is fake. The # is a commit hash.

It gave me this error when I ran npm install:

Warning: Permanently added the RSA host key for IP address '$IPADDRESS' to the list of known hosts.


Permission denied (publickey)

fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Code 128

Then I tried HTTPS, again with a commit hash:

"dependencies": {
  "repo_name": "https://github.com/ownername/reponame.git#84876fa5aasf55fssfsfafsa"

},

It worked.....kind of. It seemed to install all the depencies from the repo in the link but didn't clone the repo in the link to repo_name, it didn't seem to clone anything.

So I decided to try a different repo. One without any dependencies of its own. I used the HTTPS.... it didn't work.

I got these errors:

npm ERR! addLocal Could not install /tmp/npm-11929-4791330b/git-cache-2278328b/38b944c916c18cd4e004f07f2f476a4bb393ff8e
npm ERR! Linux 4.8.0-58-generic
npm ERR! argv "$nodepathname" "$npmpathname" "install"
npm ERR! node v7.0.0
npm ERR! npm  v3.10.8
npm ERR! code EISDIR
npm ERR! errno -21
npm ERR! syscall read

npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.

Private Repository Bitbucket

When I try my private repository via ssh via provided bitbucket string (with a commit hash), it gives me similar error messages with the other repository, it tells me:

Please make sure you have the correct access rights
npm ERR! code 128
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR! 
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

It doesn't prompt me for a username or password.

Using https on the private repo (with a commit hash, similar as before) gives me a similar error without prompting me with any username:

 remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
npm ERR! code 128
like image 536
munchschair Avatar asked Jul 21 '17 21:07

munchschair


1 Answers

You could use the postinstall hook to initiate the Git clone after npm install:

"scripts": {
    "postinstall": "git clone ... node_modules/..."
}
like image 53
Jonathan.Brink Avatar answered Oct 05 '22 03:10

Jonathan.Brink