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:

  • Migrate from GIT to TFS and retain timestamp for check-in
  • ssh-agent suddenly “lost” my key
  • How to I get diffmerge running as the merge tool for git
  • Git tool to remove lines from staging if they consist only of changes in whitespace
  • Easier way to collaborate with eclipse and GIT?
  • How to work with multiple ssh keys
  • Public Repo Github

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

    "dependencies": {
      "repo_name": "git@github.com: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
    

  • Git interactive rebase of another branch on current branch but NOT onto HEAD
  • Git: Explain why it is not silly to Sign Commits/Tags using a PGP Key
  • Pull requests that should be automatically merged aren't getting merged
  • Categorize, label or organize GitHub pull requests?
  • Why won't this display the dynamic cgi?
  • How to graft a remote branch?
  • 3 Solutions collect form web for “How do I make my repository a dependency in package.json and have it prompt me for my information?”

    There is no way for npm to prompt for a username or password. Its just not designed to work that way. There is a couple ways to make what your doing work.

    1) generate a ssh key(if you haven’t already) and add it to your bitbucket.

    2) make the private package public(ie open source it)

    3) pay for private npm packages and publish a private npm module.

    4) make a public npm package if your making open source project. You can still use npm link to link the project to the secondary project to test the packages before publishing. The dependency will be linked based on your not the folder name.

    Option 1 and 2 are generally not recommended though. Not using an npm package kind of defeats the purpose of using npm at all. You should try to avoid linking to github directly unless there are extenuating circumstances such as you needed to fork a no longer maintained project and change code.

    If you are just trying to avoid paying for private npm modules, personally I would not bother separating out the applications logic into different packages.


    Just to all kind of expound. Maybe you are trying to create a module and have never done so before so I will explain that as well. If you have a private or public application (not an npm module, and you are trying to create a public open source npm module and link to it.)

    Lets say you have the two folders.

    /git/my_application
    /git/my_new_npm_module
    

    and your new npm module has the package name “new-module” in package.json. In order to use that in your my_application app, you would need to enter that directory and run npm link on your npm module

    cd /git/my_application
    npm link ../my_new_npm_module
    

    now within any node file in your my_application app, you can use require(‘new-module’); to access what is exported from your new npm module.

    when your ready to make your package public you simply need to update the version tag in the new modules package.json and type

    npm publish
    

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

    "scripts": {
        "postinstall": "git clone ... node_modules/..."
    }
    

    After googling about the specific problem, I found the following link.
    link

    Git Baby is a git and github fan, let's start git clone.