How to install a private NPM module without my own registry?











up vote
279
down vote

favorite
167












I've taken some shared code and put it in an NPM module, one I don't want to upload to the central registry. The question is, how do I install it from other projects?



The obvious way is probably to set up my own NPM registry, but according to the documentation, that involves a lot of hassle.



Can I just install an NPM module that sits on the local filesystem, or perhaps even from git?



npm install --from-git git@server:project









share|improve this question




























    up vote
    279
    down vote

    favorite
    167












    I've taken some shared code and put it in an NPM module, one I don't want to upload to the central registry. The question is, how do I install it from other projects?



    The obvious way is probably to set up my own NPM registry, but according to the documentation, that involves a lot of hassle.



    Can I just install an NPM module that sits on the local filesystem, or perhaps even from git?



    npm install --from-git git@server:project









    share|improve this question


























      up vote
      279
      down vote

      favorite
      167









      up vote
      279
      down vote

      favorite
      167






      167





      I've taken some shared code and put it in an NPM module, one I don't want to upload to the central registry. The question is, how do I install it from other projects?



      The obvious way is probably to set up my own NPM registry, but according to the documentation, that involves a lot of hassle.



      Can I just install an NPM module that sits on the local filesystem, or perhaps even from git?



      npm install --from-git git@server:project









      share|improve this question















      I've taken some shared code and put it in an NPM module, one I don't want to upload to the central registry. The question is, how do I install it from other projects?



      The obvious way is probably to set up my own NPM registry, but according to the documentation, that involves a lot of hassle.



      Can I just install an NPM module that sits on the local filesystem, or perhaps even from git?



      npm install --from-git git@server:project






      node.js npm package npm-private-modules






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 4 '16 at 10:27









      Yves M.

      18k116897




      18k116897










      asked Apr 30 '12 at 15:33









      futlib

      3,41583350




      3,41583350
























          13 Answers
          13






          active

          oldest

          votes

















          up vote
          228
          down vote



          accepted










          cd somedir
          npm install .


          or



          npm install path/to/somedir


          somedir must contain the package.json inside it.



          It knows about git too:



          npm install git://github.com/visionmedia/express.git





          share|improve this answer



















          • 3




            The path/to/somedir solution kind of works, but then it's kind of awful because all of the require statements then have to include that relative or absolute path. Please correct me if I'm doing something wrong...
            – Luke Bayes
            Oct 25 '12 at 3:40






          • 3




            @Luke yes, you're wrong. After npm install all the files are copied to your project directory. So the paths in the require statements will be relative only to your project directory.
            – mihai
            Oct 25 '12 at 7:52






          • 3




            I'm confused by the top part and the only reason I haven't tested this myself is that I'm still learning and don't have a private module to work on. Anyway, by changing your directory to where the module is and then calling install wouldn't that just install there and not for the project you want to use it for?
            – Adam Beck
            Jan 28 '13 at 4:48






          • 8




            Side note: (a) when using git repos, you can specify a branch/commit/tag by adding a #<ref> to the end of the git url, eg git://github.com/visionmedia/express.git#v0.0.1; (b) To be safe add "private": true to the package.json of your private repos. This will make sure npm will never let you accidentally publish your secret sauce to the official npm registry. (according to debuggable.com/posts/…)
            – Rafael Xavier
            Mar 26 '13 at 19:32








          • 8




            FYI if you are serving your git up via http you'll need to npm i git+http://all/the/things.git even though git clone http://all/the/things.git works just fine
            – slf
            May 30 '13 at 19:09


















          up vote
          475
          down vote













          In your private npm modules add



          "private": true 


          to your package.json



          Then to reference the private module in another module, use this in your package.json



          {
          "name": "myapp",
          "dependencies": {
          "private-repo": "git+ssh://git@github.com:myaccount/myprivate.git#v1.0.0",
          }
          }





          share|improve this answer



















          • 47




            This is the real correct answer if you want your package.json to maintain the private repo dependency list, which is a Good Thing(tm) that you should be doing.
            – David Ellis
            Apr 24 '13 at 22:44










          • Thanks - this is perfect. One problem - it works if I don't include the # version at the end, but if I do, I get an error like this: "Error: Command failed: fatal: ambiguous argument 'v0.0.1': unknown revision or path not in the working tree." I can't find a solution to this. Do you know what's going on?
            – Jake
            Aug 14 '13 at 17:48






          • 5




            In the example it's referencing a specific tag, but if you don't have one then it'll default to master. (see git-scm.com/book/en/Git-Basics-Tagging)
            – 250R
            Aug 15 '13 at 0:17






          • 3




            I don't understand how this command line can download code from a private github repo if I am not supllying my credentials! So how can I pass my github credentials?
            – Renato Gama
            Dec 9 '13 at 19:57






          • 20




            Note that the "private": true part isn't necessary, but it will help prevent your private repo from accidentally being published to the public npm registry.
            – evanrmurphy
            Sep 10 '14 at 18:14


















          up vote
          57
          down vote














          Can I just install an NPM package that sits on the local filesystem, or perhaps even from git?




          Yes you can! From the docs https://docs.npmjs.com/cli/install




          A package is:




          • a) a folder containing a program described by a package.json file

          • b) a gzipped tarball containing (a)

          • c) a url that resolves to (b)

          • d) a <name>@<version> that is published on the registry with (c)

          • e) a <name>@<tag> that points to (d)

          • f) a <name> that has a "latest" tag satisfying (e)

          • g) a <git remote url> that resolves to (b)




          Isn't npm brilliant?






          share|improve this answer























          • Note that if you go for option b), it actually has to be a gzipped tarball, a mere zip archive won't do it. I.e. if you create your package with tar -czf my-package.tar.gz dist (assuming your dist folder also has a proper package.json file in it), then you can npm install ../my-lib/my-package.tar.gz from your other project.
            – Dániel Kis-Nagy
            Sep 17 at 11:56


















          up vote
          38
          down vote













          Update January 2016



          In addition to other answers, there is sometimes the scenario where you wish to have private modules available in a team context.



          Both Github and Bitbucket support the concept of generating a team API Key. This API key can be used as the password to perform API requests as this team.



          In your private npm modules add



          "private": true 


          to your package.json



          Then to reference the private module in another module, use this in your package.json



              {
          "name": "myapp",
          "dependencies": {
          "private-repo":
          "git+https://myteamname:aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myprivate.git",
          }
          }


          where team name = myteamname, and API Key = aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4



          Here I reference a bitbucket repo, but it is almost identical using github too.



          Finally, as an alternative, if you really don't mind paying $7 per month (as of writing) then you can now have private NPM modules out of the box.






          share|improve this answer























          • Can you use this if you want to have a global module?
            – PI.
            Jan 13 '16 at 10:31












          • This does not work for me I am afraid. Both the remote and the repository are not found. Any ideas?
            – Thomas Bormans
            Feb 3 '16 at 15:50










          • @ThomasBormans - still having trouble? Please paste (scramble your teamname / api key) what you have as your line in dependencies section of your package.json - as per above instructions. I have found this works well for both github and bitbucket private repos. Which are you using?
            – arcseldon
            Feb 3 '16 at 17:50










          • @arcseldon "name": "git+key:x-oauth-basic@bitbucket.org/user/repo.git" returns EISDIR: illegal operation on a directory, read. And "name": "git+user:key@bitbucket.org/repo.git" returns several errors including these words remote: Not Found, fatal: repository, Command failed: git clone. Any ideas?
            – Thomas Bormans
            Feb 3 '16 at 17:59










          • Try to follow the "exact" format I have given in answer: "git+https://<myteamname>:<my_key>@bitbucket.org/<my_repo_name>.git How did you generate the API key? Have you double checked it is correct in your bitbucket settings... sorry to ask the obvious, but i have near 100% confidence this should work.
            – arcseldon
            Feb 3 '16 at 18:09


















          up vote
          24
          down vote













          FWIW: I had problems with all of these answers when dealing with a private organization repository.



          The following worked for me:



          npm install -S "git+https://username@github.com/orgname/repositoryname.git"


          For example:



          npm install -S "git+https://blesh@github.com/netflix/private-repository.git"


          I'm not entirely sure why the other answers didn't work for me in this one case, because they're what I tried first before I hit Google and found this answer. And the other answers are what I've done in the past.



          Hopefully this helps someone else.






          share|improve this answer

















          • 2




            Can you use a subfolder of the git repo?
            – Chris
            Oct 10 '14 at 18:28










          • Not sure, I haven't tried that.
            – Ben Lesh
            Oct 10 '14 at 20:46


















          up vote
          7
          down vote













          I had this same problem, and after some searching around, I found Reggie (https://github.com/mbrevoort/node-reggie). It looks pretty solid. It allows for lightweight publishing of NPM modules to private servers. Not perfect (no authentication upon installation), and it's still really young, but I tested it locally, and it seems to do what it says it should do.



          That is... (and this just from their docs)



          npm install -g reggie
          reggie-server -d ~/.reggie


          then cd into your module directory and...



          reggie -u http://<host:port> publish 
          reggie -u http://127.0.0.1:8080 publish


          finally, you can install packages from reggie just by using that url either in a direct npm install command, or from within a package.json... like so



          npm install http://<host:port>/package/<name>/<version>
          npm install http://<host:port>/package/foo/1.0.0


          or..



          dependencies: {
          "foo": "http://<host:port>/package/foo/1.0.0"
          }





          share|improve this answer




























            up vote
            6
            down vote













            Structure your code in an accessible fashion like below. If this is possible for you.





            • NodeProjsAppsMainApppackage.json


            • NodeProjsModulesDataModulepackage.json





            Within MainApp @ NodProjsAppsMainApp



            npm install --S ../../Modules/DataModule


            You may need to update package.json as:



             "dependencies": {
            "datamodule": "../../Modules/DataModule"
            }


            This worked for my situation.






            share|improve this answer




























              up vote
              3
              down vote













              Starting with arcseldon's answer, I found that the team name was needed in the URL like so:



              npm install --save "git+https://myteamname@aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myteamname/myprivate.git"


              And note that the API key is only available for the team, not individual users.






              share|improve this answer






























                up vote
                2
                down vote













                Npm now provides unlimited private hosted modules for $7/user/month used like so



                cd private-project
                npm login


                in your package json set "name": " @username/private-project"



                npm publish


                then to require your project:



                cd ../new-project
                npm install --save @username/private-project





                share|improve this answer























                • Does this require a client-side login step?
                  – Aidan Hoolachan
                  Dec 16 '17 at 2:22










                • What's an alternative to this? For example, if you want to host your "package" on S3 and pull from there.
                  – Con Antonakos
                  Nov 27 at 22:19


















                up vote
                1
                down vote













                Config to install from public Github repository, even if machine is under firewall:



                dependencies: {
                "foo": "https://github.com/package/foo/tarball/master"
                }





                share|improve this answer




























                  up vote
                  1
                  down vote













                  I use the following with a private github repository:



                  npm install github:mygithubuser/myproject





                  share|improve this answer




























                    up vote
                    0
                    down vote













                    Very simple -



                    npm config set registry https://path-to-your-registry/


                    It actually sets registry = "https://path-to-your-registry" this line to /Users/<ur-machine-user-name>/.npmrc



                    All the value you have set explicitly or have been set by default can be seen by - npm config list






                    share|improve this answer






























                      up vote
                      0
                      down vote













                      This was what I was looking for:



                      # Get the latest from GitHub, public repo:
                      $ npm install username/my-new-project --save-dev
                      # Bitbucket, private repo:
                      $ npm install git+https://token:x-oauth-basic@github.com/username/my-new-project.git#master
                      $ npm install git+ssh://git@github.com/username/my-new-project.git#master

                      # … or from Bitbucket, public repo:
                      $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master --save-dev
                      # Bitbucket, private repo:
                      $ npm install git+https://username:password@bitbucket.org/username/my-new-project.git#master
                      $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master
                      # Or, if you published as npm package:
                      $ npm install my-new-project --save-dev





                      share|improve this answer





















                        Your Answer






                        StackExchange.ifUsing("editor", function () {
                        StackExchange.using("externalEditor", function () {
                        StackExchange.using("snippets", function () {
                        StackExchange.snippets.init();
                        });
                        });
                        }, "code-snippets");

                        StackExchange.ready(function() {
                        var channelOptions = {
                        tags: "".split(" "),
                        id: "1"
                        };
                        initTagRenderer("".split(" "), "".split(" "), channelOptions);

                        StackExchange.using("externalEditor", function() {
                        // Have to fire editor after snippets, if snippets enabled
                        if (StackExchange.settings.snippets.snippetsEnabled) {
                        StackExchange.using("snippets", function() {
                        createEditor();
                        });
                        }
                        else {
                        createEditor();
                        }
                        });

                        function createEditor() {
                        StackExchange.prepareEditor({
                        heartbeatType: 'answer',
                        convertImagesToLinks: true,
                        noModals: true,
                        showLowRepImageUploadWarning: true,
                        reputationToPostImages: 10,
                        bindNavPrevention: true,
                        postfix: "",
                        imageUploader: {
                        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                        allowUrls: true
                        },
                        onDemand: true,
                        discardSelector: ".discard-answer"
                        ,immediatelyShowMarkdownHelp:true
                        });


                        }
                        });














                        draft saved

                        draft discarded


















                        StackExchange.ready(
                        function () {
                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10386310%2fhow-to-install-a-private-npm-module-without-my-own-registry%23new-answer', 'question_page');
                        }
                        );

                        Post as a guest















                        Required, but never shown

























                        13 Answers
                        13






                        active

                        oldest

                        votes








                        13 Answers
                        13






                        active

                        oldest

                        votes









                        active

                        oldest

                        votes






                        active

                        oldest

                        votes








                        up vote
                        228
                        down vote



                        accepted










                        cd somedir
                        npm install .


                        or



                        npm install path/to/somedir


                        somedir must contain the package.json inside it.



                        It knows about git too:



                        npm install git://github.com/visionmedia/express.git





                        share|improve this answer



















                        • 3




                          The path/to/somedir solution kind of works, but then it's kind of awful because all of the require statements then have to include that relative or absolute path. Please correct me if I'm doing something wrong...
                          – Luke Bayes
                          Oct 25 '12 at 3:40






                        • 3




                          @Luke yes, you're wrong. After npm install all the files are copied to your project directory. So the paths in the require statements will be relative only to your project directory.
                          – mihai
                          Oct 25 '12 at 7:52






                        • 3




                          I'm confused by the top part and the only reason I haven't tested this myself is that I'm still learning and don't have a private module to work on. Anyway, by changing your directory to where the module is and then calling install wouldn't that just install there and not for the project you want to use it for?
                          – Adam Beck
                          Jan 28 '13 at 4:48






                        • 8




                          Side note: (a) when using git repos, you can specify a branch/commit/tag by adding a #<ref> to the end of the git url, eg git://github.com/visionmedia/express.git#v0.0.1; (b) To be safe add "private": true to the package.json of your private repos. This will make sure npm will never let you accidentally publish your secret sauce to the official npm registry. (according to debuggable.com/posts/…)
                          – Rafael Xavier
                          Mar 26 '13 at 19:32








                        • 8




                          FYI if you are serving your git up via http you'll need to npm i git+http://all/the/things.git even though git clone http://all/the/things.git works just fine
                          – slf
                          May 30 '13 at 19:09















                        up vote
                        228
                        down vote



                        accepted










                        cd somedir
                        npm install .


                        or



                        npm install path/to/somedir


                        somedir must contain the package.json inside it.



                        It knows about git too:



                        npm install git://github.com/visionmedia/express.git





                        share|improve this answer



















                        • 3




                          The path/to/somedir solution kind of works, but then it's kind of awful because all of the require statements then have to include that relative or absolute path. Please correct me if I'm doing something wrong...
                          – Luke Bayes
                          Oct 25 '12 at 3:40






                        • 3




                          @Luke yes, you're wrong. After npm install all the files are copied to your project directory. So the paths in the require statements will be relative only to your project directory.
                          – mihai
                          Oct 25 '12 at 7:52






                        • 3




                          I'm confused by the top part and the only reason I haven't tested this myself is that I'm still learning and don't have a private module to work on. Anyway, by changing your directory to where the module is and then calling install wouldn't that just install there and not for the project you want to use it for?
                          – Adam Beck
                          Jan 28 '13 at 4:48






                        • 8




                          Side note: (a) when using git repos, you can specify a branch/commit/tag by adding a #<ref> to the end of the git url, eg git://github.com/visionmedia/express.git#v0.0.1; (b) To be safe add "private": true to the package.json of your private repos. This will make sure npm will never let you accidentally publish your secret sauce to the official npm registry. (according to debuggable.com/posts/…)
                          – Rafael Xavier
                          Mar 26 '13 at 19:32








                        • 8




                          FYI if you are serving your git up via http you'll need to npm i git+http://all/the/things.git even though git clone http://all/the/things.git works just fine
                          – slf
                          May 30 '13 at 19:09













                        up vote
                        228
                        down vote



                        accepted







                        up vote
                        228
                        down vote



                        accepted






                        cd somedir
                        npm install .


                        or



                        npm install path/to/somedir


                        somedir must contain the package.json inside it.



                        It knows about git too:



                        npm install git://github.com/visionmedia/express.git





                        share|improve this answer














                        cd somedir
                        npm install .


                        or



                        npm install path/to/somedir


                        somedir must contain the package.json inside it.



                        It knows about git too:



                        npm install git://github.com/visionmedia/express.git






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Apr 30 '12 at 21:47

























                        answered Apr 30 '12 at 18:44









                        mihai

                        23.1k73968




                        23.1k73968








                        • 3




                          The path/to/somedir solution kind of works, but then it's kind of awful because all of the require statements then have to include that relative or absolute path. Please correct me if I'm doing something wrong...
                          – Luke Bayes
                          Oct 25 '12 at 3:40






                        • 3




                          @Luke yes, you're wrong. After npm install all the files are copied to your project directory. So the paths in the require statements will be relative only to your project directory.
                          – mihai
                          Oct 25 '12 at 7:52






                        • 3




                          I'm confused by the top part and the only reason I haven't tested this myself is that I'm still learning and don't have a private module to work on. Anyway, by changing your directory to where the module is and then calling install wouldn't that just install there and not for the project you want to use it for?
                          – Adam Beck
                          Jan 28 '13 at 4:48






                        • 8




                          Side note: (a) when using git repos, you can specify a branch/commit/tag by adding a #<ref> to the end of the git url, eg git://github.com/visionmedia/express.git#v0.0.1; (b) To be safe add "private": true to the package.json of your private repos. This will make sure npm will never let you accidentally publish your secret sauce to the official npm registry. (according to debuggable.com/posts/…)
                          – Rafael Xavier
                          Mar 26 '13 at 19:32








                        • 8




                          FYI if you are serving your git up via http you'll need to npm i git+http://all/the/things.git even though git clone http://all/the/things.git works just fine
                          – slf
                          May 30 '13 at 19:09














                        • 3




                          The path/to/somedir solution kind of works, but then it's kind of awful because all of the require statements then have to include that relative or absolute path. Please correct me if I'm doing something wrong...
                          – Luke Bayes
                          Oct 25 '12 at 3:40






                        • 3




                          @Luke yes, you're wrong. After npm install all the files are copied to your project directory. So the paths in the require statements will be relative only to your project directory.
                          – mihai
                          Oct 25 '12 at 7:52






                        • 3




                          I'm confused by the top part and the only reason I haven't tested this myself is that I'm still learning and don't have a private module to work on. Anyway, by changing your directory to where the module is and then calling install wouldn't that just install there and not for the project you want to use it for?
                          – Adam Beck
                          Jan 28 '13 at 4:48






                        • 8




                          Side note: (a) when using git repos, you can specify a branch/commit/tag by adding a #<ref> to the end of the git url, eg git://github.com/visionmedia/express.git#v0.0.1; (b) To be safe add "private": true to the package.json of your private repos. This will make sure npm will never let you accidentally publish your secret sauce to the official npm registry. (according to debuggable.com/posts/…)
                          – Rafael Xavier
                          Mar 26 '13 at 19:32








                        • 8




                          FYI if you are serving your git up via http you'll need to npm i git+http://all/the/things.git even though git clone http://all/the/things.git works just fine
                          – slf
                          May 30 '13 at 19:09








                        3




                        3




                        The path/to/somedir solution kind of works, but then it's kind of awful because all of the require statements then have to include that relative or absolute path. Please correct me if I'm doing something wrong...
                        – Luke Bayes
                        Oct 25 '12 at 3:40




                        The path/to/somedir solution kind of works, but then it's kind of awful because all of the require statements then have to include that relative or absolute path. Please correct me if I'm doing something wrong...
                        – Luke Bayes
                        Oct 25 '12 at 3:40




                        3




                        3




                        @Luke yes, you're wrong. After npm install all the files are copied to your project directory. So the paths in the require statements will be relative only to your project directory.
                        – mihai
                        Oct 25 '12 at 7:52




                        @Luke yes, you're wrong. After npm install all the files are copied to your project directory. So the paths in the require statements will be relative only to your project directory.
                        – mihai
                        Oct 25 '12 at 7:52




                        3




                        3




                        I'm confused by the top part and the only reason I haven't tested this myself is that I'm still learning and don't have a private module to work on. Anyway, by changing your directory to where the module is and then calling install wouldn't that just install there and not for the project you want to use it for?
                        – Adam Beck
                        Jan 28 '13 at 4:48




                        I'm confused by the top part and the only reason I haven't tested this myself is that I'm still learning and don't have a private module to work on. Anyway, by changing your directory to where the module is and then calling install wouldn't that just install there and not for the project you want to use it for?
                        – Adam Beck
                        Jan 28 '13 at 4:48




                        8




                        8




                        Side note: (a) when using git repos, you can specify a branch/commit/tag by adding a #<ref> to the end of the git url, eg git://github.com/visionmedia/express.git#v0.0.1; (b) To be safe add "private": true to the package.json of your private repos. This will make sure npm will never let you accidentally publish your secret sauce to the official npm registry. (according to debuggable.com/posts/…)
                        – Rafael Xavier
                        Mar 26 '13 at 19:32






                        Side note: (a) when using git repos, you can specify a branch/commit/tag by adding a #<ref> to the end of the git url, eg git://github.com/visionmedia/express.git#v0.0.1; (b) To be safe add "private": true to the package.json of your private repos. This will make sure npm will never let you accidentally publish your secret sauce to the official npm registry. (according to debuggable.com/posts/…)
                        – Rafael Xavier
                        Mar 26 '13 at 19:32






                        8




                        8




                        FYI if you are serving your git up via http you'll need to npm i git+http://all/the/things.git even though git clone http://all/the/things.git works just fine
                        – slf
                        May 30 '13 at 19:09




                        FYI if you are serving your git up via http you'll need to npm i git+http://all/the/things.git even though git clone http://all/the/things.git works just fine
                        – slf
                        May 30 '13 at 19:09












                        up vote
                        475
                        down vote













                        In your private npm modules add



                        "private": true 


                        to your package.json



                        Then to reference the private module in another module, use this in your package.json



                        {
                        "name": "myapp",
                        "dependencies": {
                        "private-repo": "git+ssh://git@github.com:myaccount/myprivate.git#v1.0.0",
                        }
                        }





                        share|improve this answer



















                        • 47




                          This is the real correct answer if you want your package.json to maintain the private repo dependency list, which is a Good Thing(tm) that you should be doing.
                          – David Ellis
                          Apr 24 '13 at 22:44










                        • Thanks - this is perfect. One problem - it works if I don't include the # version at the end, but if I do, I get an error like this: "Error: Command failed: fatal: ambiguous argument 'v0.0.1': unknown revision or path not in the working tree." I can't find a solution to this. Do you know what's going on?
                          – Jake
                          Aug 14 '13 at 17:48






                        • 5




                          In the example it's referencing a specific tag, but if you don't have one then it'll default to master. (see git-scm.com/book/en/Git-Basics-Tagging)
                          – 250R
                          Aug 15 '13 at 0:17






                        • 3




                          I don't understand how this command line can download code from a private github repo if I am not supllying my credentials! So how can I pass my github credentials?
                          – Renato Gama
                          Dec 9 '13 at 19:57






                        • 20




                          Note that the "private": true part isn't necessary, but it will help prevent your private repo from accidentally being published to the public npm registry.
                          – evanrmurphy
                          Sep 10 '14 at 18:14















                        up vote
                        475
                        down vote













                        In your private npm modules add



                        "private": true 


                        to your package.json



                        Then to reference the private module in another module, use this in your package.json



                        {
                        "name": "myapp",
                        "dependencies": {
                        "private-repo": "git+ssh://git@github.com:myaccount/myprivate.git#v1.0.0",
                        }
                        }





                        share|improve this answer



















                        • 47




                          This is the real correct answer if you want your package.json to maintain the private repo dependency list, which is a Good Thing(tm) that you should be doing.
                          – David Ellis
                          Apr 24 '13 at 22:44










                        • Thanks - this is perfect. One problem - it works if I don't include the # version at the end, but if I do, I get an error like this: "Error: Command failed: fatal: ambiguous argument 'v0.0.1': unknown revision or path not in the working tree." I can't find a solution to this. Do you know what's going on?
                          – Jake
                          Aug 14 '13 at 17:48






                        • 5




                          In the example it's referencing a specific tag, but if you don't have one then it'll default to master. (see git-scm.com/book/en/Git-Basics-Tagging)
                          – 250R
                          Aug 15 '13 at 0:17






                        • 3




                          I don't understand how this command line can download code from a private github repo if I am not supllying my credentials! So how can I pass my github credentials?
                          – Renato Gama
                          Dec 9 '13 at 19:57






                        • 20




                          Note that the "private": true part isn't necessary, but it will help prevent your private repo from accidentally being published to the public npm registry.
                          – evanrmurphy
                          Sep 10 '14 at 18:14













                        up vote
                        475
                        down vote










                        up vote
                        475
                        down vote









                        In your private npm modules add



                        "private": true 


                        to your package.json



                        Then to reference the private module in another module, use this in your package.json



                        {
                        "name": "myapp",
                        "dependencies": {
                        "private-repo": "git+ssh://git@github.com:myaccount/myprivate.git#v1.0.0",
                        }
                        }





                        share|improve this answer














                        In your private npm modules add



                        "private": true 


                        to your package.json



                        Then to reference the private module in another module, use this in your package.json



                        {
                        "name": "myapp",
                        "dependencies": {
                        "private-repo": "git+ssh://git@github.com:myaccount/myprivate.git#v1.0.0",
                        }
                        }






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited May 21 '14 at 16:27









                        heckj

                        4,57422635




                        4,57422635










                        answered Apr 30 '12 at 23:09









                        250R

                        22.2k62724




                        22.2k62724








                        • 47




                          This is the real correct answer if you want your package.json to maintain the private repo dependency list, which is a Good Thing(tm) that you should be doing.
                          – David Ellis
                          Apr 24 '13 at 22:44










                        • Thanks - this is perfect. One problem - it works if I don't include the # version at the end, but if I do, I get an error like this: "Error: Command failed: fatal: ambiguous argument 'v0.0.1': unknown revision or path not in the working tree." I can't find a solution to this. Do you know what's going on?
                          – Jake
                          Aug 14 '13 at 17:48






                        • 5




                          In the example it's referencing a specific tag, but if you don't have one then it'll default to master. (see git-scm.com/book/en/Git-Basics-Tagging)
                          – 250R
                          Aug 15 '13 at 0:17






                        • 3




                          I don't understand how this command line can download code from a private github repo if I am not supllying my credentials! So how can I pass my github credentials?
                          – Renato Gama
                          Dec 9 '13 at 19:57






                        • 20




                          Note that the "private": true part isn't necessary, but it will help prevent your private repo from accidentally being published to the public npm registry.
                          – evanrmurphy
                          Sep 10 '14 at 18:14














                        • 47




                          This is the real correct answer if you want your package.json to maintain the private repo dependency list, which is a Good Thing(tm) that you should be doing.
                          – David Ellis
                          Apr 24 '13 at 22:44










                        • Thanks - this is perfect. One problem - it works if I don't include the # version at the end, but if I do, I get an error like this: "Error: Command failed: fatal: ambiguous argument 'v0.0.1': unknown revision or path not in the working tree." I can't find a solution to this. Do you know what's going on?
                          – Jake
                          Aug 14 '13 at 17:48






                        • 5




                          In the example it's referencing a specific tag, but if you don't have one then it'll default to master. (see git-scm.com/book/en/Git-Basics-Tagging)
                          – 250R
                          Aug 15 '13 at 0:17






                        • 3




                          I don't understand how this command line can download code from a private github repo if I am not supllying my credentials! So how can I pass my github credentials?
                          – Renato Gama
                          Dec 9 '13 at 19:57






                        • 20




                          Note that the "private": true part isn't necessary, but it will help prevent your private repo from accidentally being published to the public npm registry.
                          – evanrmurphy
                          Sep 10 '14 at 18:14








                        47




                        47




                        This is the real correct answer if you want your package.json to maintain the private repo dependency list, which is a Good Thing(tm) that you should be doing.
                        – David Ellis
                        Apr 24 '13 at 22:44




                        This is the real correct answer if you want your package.json to maintain the private repo dependency list, which is a Good Thing(tm) that you should be doing.
                        – David Ellis
                        Apr 24 '13 at 22:44












                        Thanks - this is perfect. One problem - it works if I don't include the # version at the end, but if I do, I get an error like this: "Error: Command failed: fatal: ambiguous argument 'v0.0.1': unknown revision or path not in the working tree." I can't find a solution to this. Do you know what's going on?
                        – Jake
                        Aug 14 '13 at 17:48




                        Thanks - this is perfect. One problem - it works if I don't include the # version at the end, but if I do, I get an error like this: "Error: Command failed: fatal: ambiguous argument 'v0.0.1': unknown revision or path not in the working tree." I can't find a solution to this. Do you know what's going on?
                        – Jake
                        Aug 14 '13 at 17:48




                        5




                        5




                        In the example it's referencing a specific tag, but if you don't have one then it'll default to master. (see git-scm.com/book/en/Git-Basics-Tagging)
                        – 250R
                        Aug 15 '13 at 0:17




                        In the example it's referencing a specific tag, but if you don't have one then it'll default to master. (see git-scm.com/book/en/Git-Basics-Tagging)
                        – 250R
                        Aug 15 '13 at 0:17




                        3




                        3




                        I don't understand how this command line can download code from a private github repo if I am not supllying my credentials! So how can I pass my github credentials?
                        – Renato Gama
                        Dec 9 '13 at 19:57




                        I don't understand how this command line can download code from a private github repo if I am not supllying my credentials! So how can I pass my github credentials?
                        – Renato Gama
                        Dec 9 '13 at 19:57




                        20




                        20




                        Note that the "private": true part isn't necessary, but it will help prevent your private repo from accidentally being published to the public npm registry.
                        – evanrmurphy
                        Sep 10 '14 at 18:14




                        Note that the "private": true part isn't necessary, but it will help prevent your private repo from accidentally being published to the public npm registry.
                        – evanrmurphy
                        Sep 10 '14 at 18:14










                        up vote
                        57
                        down vote














                        Can I just install an NPM package that sits on the local filesystem, or perhaps even from git?




                        Yes you can! From the docs https://docs.npmjs.com/cli/install




                        A package is:




                        • a) a folder containing a program described by a package.json file

                        • b) a gzipped tarball containing (a)

                        • c) a url that resolves to (b)

                        • d) a <name>@<version> that is published on the registry with (c)

                        • e) a <name>@<tag> that points to (d)

                        • f) a <name> that has a "latest" tag satisfying (e)

                        • g) a <git remote url> that resolves to (b)




                        Isn't npm brilliant?






                        share|improve this answer























                        • Note that if you go for option b), it actually has to be a gzipped tarball, a mere zip archive won't do it. I.e. if you create your package with tar -czf my-package.tar.gz dist (assuming your dist folder also has a proper package.json file in it), then you can npm install ../my-lib/my-package.tar.gz from your other project.
                          – Dániel Kis-Nagy
                          Sep 17 at 11:56















                        up vote
                        57
                        down vote














                        Can I just install an NPM package that sits on the local filesystem, or perhaps even from git?




                        Yes you can! From the docs https://docs.npmjs.com/cli/install




                        A package is:




                        • a) a folder containing a program described by a package.json file

                        • b) a gzipped tarball containing (a)

                        • c) a url that resolves to (b)

                        • d) a <name>@<version> that is published on the registry with (c)

                        • e) a <name>@<tag> that points to (d)

                        • f) a <name> that has a "latest" tag satisfying (e)

                        • g) a <git remote url> that resolves to (b)




                        Isn't npm brilliant?






                        share|improve this answer























                        • Note that if you go for option b), it actually has to be a gzipped tarball, a mere zip archive won't do it. I.e. if you create your package with tar -czf my-package.tar.gz dist (assuming your dist folder also has a proper package.json file in it), then you can npm install ../my-lib/my-package.tar.gz from your other project.
                          – Dániel Kis-Nagy
                          Sep 17 at 11:56













                        up vote
                        57
                        down vote










                        up vote
                        57
                        down vote










                        Can I just install an NPM package that sits on the local filesystem, or perhaps even from git?




                        Yes you can! From the docs https://docs.npmjs.com/cli/install




                        A package is:




                        • a) a folder containing a program described by a package.json file

                        • b) a gzipped tarball containing (a)

                        • c) a url that resolves to (b)

                        • d) a <name>@<version> that is published on the registry with (c)

                        • e) a <name>@<tag> that points to (d)

                        • f) a <name> that has a "latest" tag satisfying (e)

                        • g) a <git remote url> that resolves to (b)




                        Isn't npm brilliant?






                        share|improve this answer















                        Can I just install an NPM package that sits on the local filesystem, or perhaps even from git?




                        Yes you can! From the docs https://docs.npmjs.com/cli/install




                        A package is:




                        • a) a folder containing a program described by a package.json file

                        • b) a gzipped tarball containing (a)

                        • c) a url that resolves to (b)

                        • d) a <name>@<version> that is published on the registry with (c)

                        • e) a <name>@<tag> that points to (d)

                        • f) a <name> that has a "latest" tag satisfying (e)

                        • g) a <git remote url> that resolves to (b)




                        Isn't npm brilliant?







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jan 14 '15 at 16:31

























                        answered May 3 '12 at 9:39









                        Colonel Panic

                        79.5k60295389




                        79.5k60295389












                        • Note that if you go for option b), it actually has to be a gzipped tarball, a mere zip archive won't do it. I.e. if you create your package with tar -czf my-package.tar.gz dist (assuming your dist folder also has a proper package.json file in it), then you can npm install ../my-lib/my-package.tar.gz from your other project.
                          – Dániel Kis-Nagy
                          Sep 17 at 11:56


















                        • Note that if you go for option b), it actually has to be a gzipped tarball, a mere zip archive won't do it. I.e. if you create your package with tar -czf my-package.tar.gz dist (assuming your dist folder also has a proper package.json file in it), then you can npm install ../my-lib/my-package.tar.gz from your other project.
                          – Dániel Kis-Nagy
                          Sep 17 at 11:56
















                        Note that if you go for option b), it actually has to be a gzipped tarball, a mere zip archive won't do it. I.e. if you create your package with tar -czf my-package.tar.gz dist (assuming your dist folder also has a proper package.json file in it), then you can npm install ../my-lib/my-package.tar.gz from your other project.
                        – Dániel Kis-Nagy
                        Sep 17 at 11:56




                        Note that if you go for option b), it actually has to be a gzipped tarball, a mere zip archive won't do it. I.e. if you create your package with tar -czf my-package.tar.gz dist (assuming your dist folder also has a proper package.json file in it), then you can npm install ../my-lib/my-package.tar.gz from your other project.
                        – Dániel Kis-Nagy
                        Sep 17 at 11:56










                        up vote
                        38
                        down vote













                        Update January 2016



                        In addition to other answers, there is sometimes the scenario where you wish to have private modules available in a team context.



                        Both Github and Bitbucket support the concept of generating a team API Key. This API key can be used as the password to perform API requests as this team.



                        In your private npm modules add



                        "private": true 


                        to your package.json



                        Then to reference the private module in another module, use this in your package.json



                            {
                        "name": "myapp",
                        "dependencies": {
                        "private-repo":
                        "git+https://myteamname:aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myprivate.git",
                        }
                        }


                        where team name = myteamname, and API Key = aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4



                        Here I reference a bitbucket repo, but it is almost identical using github too.



                        Finally, as an alternative, if you really don't mind paying $7 per month (as of writing) then you can now have private NPM modules out of the box.






                        share|improve this answer























                        • Can you use this if you want to have a global module?
                          – PI.
                          Jan 13 '16 at 10:31












                        • This does not work for me I am afraid. Both the remote and the repository are not found. Any ideas?
                          – Thomas Bormans
                          Feb 3 '16 at 15:50










                        • @ThomasBormans - still having trouble? Please paste (scramble your teamname / api key) what you have as your line in dependencies section of your package.json - as per above instructions. I have found this works well for both github and bitbucket private repos. Which are you using?
                          – arcseldon
                          Feb 3 '16 at 17:50










                        • @arcseldon "name": "git+key:x-oauth-basic@bitbucket.org/user/repo.git" returns EISDIR: illegal operation on a directory, read. And "name": "git+user:key@bitbucket.org/repo.git" returns several errors including these words remote: Not Found, fatal: repository, Command failed: git clone. Any ideas?
                          – Thomas Bormans
                          Feb 3 '16 at 17:59










                        • Try to follow the "exact" format I have given in answer: "git+https://<myteamname>:<my_key>@bitbucket.org/<my_repo_name>.git How did you generate the API key? Have you double checked it is correct in your bitbucket settings... sorry to ask the obvious, but i have near 100% confidence this should work.
                          – arcseldon
                          Feb 3 '16 at 18:09















                        up vote
                        38
                        down vote













                        Update January 2016



                        In addition to other answers, there is sometimes the scenario where you wish to have private modules available in a team context.



                        Both Github and Bitbucket support the concept of generating a team API Key. This API key can be used as the password to perform API requests as this team.



                        In your private npm modules add



                        "private": true 


                        to your package.json



                        Then to reference the private module in another module, use this in your package.json



                            {
                        "name": "myapp",
                        "dependencies": {
                        "private-repo":
                        "git+https://myteamname:aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myprivate.git",
                        }
                        }


                        where team name = myteamname, and API Key = aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4



                        Here I reference a bitbucket repo, but it is almost identical using github too.



                        Finally, as an alternative, if you really don't mind paying $7 per month (as of writing) then you can now have private NPM modules out of the box.






                        share|improve this answer























                        • Can you use this if you want to have a global module?
                          – PI.
                          Jan 13 '16 at 10:31












                        • This does not work for me I am afraid. Both the remote and the repository are not found. Any ideas?
                          – Thomas Bormans
                          Feb 3 '16 at 15:50










                        • @ThomasBormans - still having trouble? Please paste (scramble your teamname / api key) what you have as your line in dependencies section of your package.json - as per above instructions. I have found this works well for both github and bitbucket private repos. Which are you using?
                          – arcseldon
                          Feb 3 '16 at 17:50










                        • @arcseldon "name": "git+key:x-oauth-basic@bitbucket.org/user/repo.git" returns EISDIR: illegal operation on a directory, read. And "name": "git+user:key@bitbucket.org/repo.git" returns several errors including these words remote: Not Found, fatal: repository, Command failed: git clone. Any ideas?
                          – Thomas Bormans
                          Feb 3 '16 at 17:59










                        • Try to follow the "exact" format I have given in answer: "git+https://<myteamname>:<my_key>@bitbucket.org/<my_repo_name>.git How did you generate the API key? Have you double checked it is correct in your bitbucket settings... sorry to ask the obvious, but i have near 100% confidence this should work.
                          – arcseldon
                          Feb 3 '16 at 18:09













                        up vote
                        38
                        down vote










                        up vote
                        38
                        down vote









                        Update January 2016



                        In addition to other answers, there is sometimes the scenario where you wish to have private modules available in a team context.



                        Both Github and Bitbucket support the concept of generating a team API Key. This API key can be used as the password to perform API requests as this team.



                        In your private npm modules add



                        "private": true 


                        to your package.json



                        Then to reference the private module in another module, use this in your package.json



                            {
                        "name": "myapp",
                        "dependencies": {
                        "private-repo":
                        "git+https://myteamname:aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myprivate.git",
                        }
                        }


                        where team name = myteamname, and API Key = aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4



                        Here I reference a bitbucket repo, but it is almost identical using github too.



                        Finally, as an alternative, if you really don't mind paying $7 per month (as of writing) then you can now have private NPM modules out of the box.






                        share|improve this answer














                        Update January 2016



                        In addition to other answers, there is sometimes the scenario where you wish to have private modules available in a team context.



                        Both Github and Bitbucket support the concept of generating a team API Key. This API key can be used as the password to perform API requests as this team.



                        In your private npm modules add



                        "private": true 


                        to your package.json



                        Then to reference the private module in another module, use this in your package.json



                            {
                        "name": "myapp",
                        "dependencies": {
                        "private-repo":
                        "git+https://myteamname:aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myprivate.git",
                        }
                        }


                        where team name = myteamname, and API Key = aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4



                        Here I reference a bitbucket repo, but it is almost identical using github too.



                        Finally, as an alternative, if you really don't mind paying $7 per month (as of writing) then you can now have private NPM modules out of the box.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jan 13 '16 at 0:11

























                        answered Jan 6 '16 at 11:27









                        arcseldon

                        19.4k36888




                        19.4k36888












                        • Can you use this if you want to have a global module?
                          – PI.
                          Jan 13 '16 at 10:31












                        • This does not work for me I am afraid. Both the remote and the repository are not found. Any ideas?
                          – Thomas Bormans
                          Feb 3 '16 at 15:50










                        • @ThomasBormans - still having trouble? Please paste (scramble your teamname / api key) what you have as your line in dependencies section of your package.json - as per above instructions. I have found this works well for both github and bitbucket private repos. Which are you using?
                          – arcseldon
                          Feb 3 '16 at 17:50










                        • @arcseldon "name": "git+key:x-oauth-basic@bitbucket.org/user/repo.git" returns EISDIR: illegal operation on a directory, read. And "name": "git+user:key@bitbucket.org/repo.git" returns several errors including these words remote: Not Found, fatal: repository, Command failed: git clone. Any ideas?
                          – Thomas Bormans
                          Feb 3 '16 at 17:59










                        • Try to follow the "exact" format I have given in answer: "git+https://<myteamname>:<my_key>@bitbucket.org/<my_repo_name>.git How did you generate the API key? Have you double checked it is correct in your bitbucket settings... sorry to ask the obvious, but i have near 100% confidence this should work.
                          – arcseldon
                          Feb 3 '16 at 18:09


















                        • Can you use this if you want to have a global module?
                          – PI.
                          Jan 13 '16 at 10:31












                        • This does not work for me I am afraid. Both the remote and the repository are not found. Any ideas?
                          – Thomas Bormans
                          Feb 3 '16 at 15:50










                        • @ThomasBormans - still having trouble? Please paste (scramble your teamname / api key) what you have as your line in dependencies section of your package.json - as per above instructions. I have found this works well for both github and bitbucket private repos. Which are you using?
                          – arcseldon
                          Feb 3 '16 at 17:50










                        • @arcseldon "name": "git+key:x-oauth-basic@bitbucket.org/user/repo.git" returns EISDIR: illegal operation on a directory, read. And "name": "git+user:key@bitbucket.org/repo.git" returns several errors including these words remote: Not Found, fatal: repository, Command failed: git clone. Any ideas?
                          – Thomas Bormans
                          Feb 3 '16 at 17:59










                        • Try to follow the "exact" format I have given in answer: "git+https://<myteamname>:<my_key>@bitbucket.org/<my_repo_name>.git How did you generate the API key? Have you double checked it is correct in your bitbucket settings... sorry to ask the obvious, but i have near 100% confidence this should work.
                          – arcseldon
                          Feb 3 '16 at 18:09
















                        Can you use this if you want to have a global module?
                        – PI.
                        Jan 13 '16 at 10:31






                        Can you use this if you want to have a global module?
                        – PI.
                        Jan 13 '16 at 10:31














                        This does not work for me I am afraid. Both the remote and the repository are not found. Any ideas?
                        – Thomas Bormans
                        Feb 3 '16 at 15:50




                        This does not work for me I am afraid. Both the remote and the repository are not found. Any ideas?
                        – Thomas Bormans
                        Feb 3 '16 at 15:50












                        @ThomasBormans - still having trouble? Please paste (scramble your teamname / api key) what you have as your line in dependencies section of your package.json - as per above instructions. I have found this works well for both github and bitbucket private repos. Which are you using?
                        – arcseldon
                        Feb 3 '16 at 17:50




                        @ThomasBormans - still having trouble? Please paste (scramble your teamname / api key) what you have as your line in dependencies section of your package.json - as per above instructions. I have found this works well for both github and bitbucket private repos. Which are you using?
                        – arcseldon
                        Feb 3 '16 at 17:50












                        @arcseldon "name": "git+key:x-oauth-basic@bitbucket.org/user/repo.git" returns EISDIR: illegal operation on a directory, read. And "name": "git+user:key@bitbucket.org/repo.git" returns several errors including these words remote: Not Found, fatal: repository, Command failed: git clone. Any ideas?
                        – Thomas Bormans
                        Feb 3 '16 at 17:59




                        @arcseldon "name": "git+key:x-oauth-basic@bitbucket.org/user/repo.git" returns EISDIR: illegal operation on a directory, read. And "name": "git+user:key@bitbucket.org/repo.git" returns several errors including these words remote: Not Found, fatal: repository, Command failed: git clone. Any ideas?
                        – Thomas Bormans
                        Feb 3 '16 at 17:59












                        Try to follow the "exact" format I have given in answer: "git+https://<myteamname>:<my_key>@bitbucket.org/<my_repo_name>.git How did you generate the API key? Have you double checked it is correct in your bitbucket settings... sorry to ask the obvious, but i have near 100% confidence this should work.
                        – arcseldon
                        Feb 3 '16 at 18:09




                        Try to follow the "exact" format I have given in answer: "git+https://<myteamname>:<my_key>@bitbucket.org/<my_repo_name>.git How did you generate the API key? Have you double checked it is correct in your bitbucket settings... sorry to ask the obvious, but i have near 100% confidence this should work.
                        – arcseldon
                        Feb 3 '16 at 18:09










                        up vote
                        24
                        down vote













                        FWIW: I had problems with all of these answers when dealing with a private organization repository.



                        The following worked for me:



                        npm install -S "git+https://username@github.com/orgname/repositoryname.git"


                        For example:



                        npm install -S "git+https://blesh@github.com/netflix/private-repository.git"


                        I'm not entirely sure why the other answers didn't work for me in this one case, because they're what I tried first before I hit Google and found this answer. And the other answers are what I've done in the past.



                        Hopefully this helps someone else.






                        share|improve this answer

















                        • 2




                          Can you use a subfolder of the git repo?
                          – Chris
                          Oct 10 '14 at 18:28










                        • Not sure, I haven't tried that.
                          – Ben Lesh
                          Oct 10 '14 at 20:46















                        up vote
                        24
                        down vote













                        FWIW: I had problems with all of these answers when dealing with a private organization repository.



                        The following worked for me:



                        npm install -S "git+https://username@github.com/orgname/repositoryname.git"


                        For example:



                        npm install -S "git+https://blesh@github.com/netflix/private-repository.git"


                        I'm not entirely sure why the other answers didn't work for me in this one case, because they're what I tried first before I hit Google and found this answer. And the other answers are what I've done in the past.



                        Hopefully this helps someone else.






                        share|improve this answer

















                        • 2




                          Can you use a subfolder of the git repo?
                          – Chris
                          Oct 10 '14 at 18:28










                        • Not sure, I haven't tried that.
                          – Ben Lesh
                          Oct 10 '14 at 20:46













                        up vote
                        24
                        down vote










                        up vote
                        24
                        down vote









                        FWIW: I had problems with all of these answers when dealing with a private organization repository.



                        The following worked for me:



                        npm install -S "git+https://username@github.com/orgname/repositoryname.git"


                        For example:



                        npm install -S "git+https://blesh@github.com/netflix/private-repository.git"


                        I'm not entirely sure why the other answers didn't work for me in this one case, because they're what I tried first before I hit Google and found this answer. And the other answers are what I've done in the past.



                        Hopefully this helps someone else.






                        share|improve this answer












                        FWIW: I had problems with all of these answers when dealing with a private organization repository.



                        The following worked for me:



                        npm install -S "git+https://username@github.com/orgname/repositoryname.git"


                        For example:



                        npm install -S "git+https://blesh@github.com/netflix/private-repository.git"


                        I'm not entirely sure why the other answers didn't work for me in this one case, because they're what I tried first before I hit Google and found this answer. And the other answers are what I've done in the past.



                        Hopefully this helps someone else.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jun 20 '14 at 21:45









                        Ben Lesh

                        95.6k44236226




                        95.6k44236226








                        • 2




                          Can you use a subfolder of the git repo?
                          – Chris
                          Oct 10 '14 at 18:28










                        • Not sure, I haven't tried that.
                          – Ben Lesh
                          Oct 10 '14 at 20:46














                        • 2




                          Can you use a subfolder of the git repo?
                          – Chris
                          Oct 10 '14 at 18:28










                        • Not sure, I haven't tried that.
                          – Ben Lesh
                          Oct 10 '14 at 20:46








                        2




                        2




                        Can you use a subfolder of the git repo?
                        – Chris
                        Oct 10 '14 at 18:28




                        Can you use a subfolder of the git repo?
                        – Chris
                        Oct 10 '14 at 18:28












                        Not sure, I haven't tried that.
                        – Ben Lesh
                        Oct 10 '14 at 20:46




                        Not sure, I haven't tried that.
                        – Ben Lesh
                        Oct 10 '14 at 20:46










                        up vote
                        7
                        down vote













                        I had this same problem, and after some searching around, I found Reggie (https://github.com/mbrevoort/node-reggie). It looks pretty solid. It allows for lightweight publishing of NPM modules to private servers. Not perfect (no authentication upon installation), and it's still really young, but I tested it locally, and it seems to do what it says it should do.



                        That is... (and this just from their docs)



                        npm install -g reggie
                        reggie-server -d ~/.reggie


                        then cd into your module directory and...



                        reggie -u http://<host:port> publish 
                        reggie -u http://127.0.0.1:8080 publish


                        finally, you can install packages from reggie just by using that url either in a direct npm install command, or from within a package.json... like so



                        npm install http://<host:port>/package/<name>/<version>
                        npm install http://<host:port>/package/foo/1.0.0


                        or..



                        dependencies: {
                        "foo": "http://<host:port>/package/foo/1.0.0"
                        }





                        share|improve this answer

























                          up vote
                          7
                          down vote













                          I had this same problem, and after some searching around, I found Reggie (https://github.com/mbrevoort/node-reggie). It looks pretty solid. It allows for lightweight publishing of NPM modules to private servers. Not perfect (no authentication upon installation), and it's still really young, but I tested it locally, and it seems to do what it says it should do.



                          That is... (and this just from their docs)



                          npm install -g reggie
                          reggie-server -d ~/.reggie


                          then cd into your module directory and...



                          reggie -u http://<host:port> publish 
                          reggie -u http://127.0.0.1:8080 publish


                          finally, you can install packages from reggie just by using that url either in a direct npm install command, or from within a package.json... like so



                          npm install http://<host:port>/package/<name>/<version>
                          npm install http://<host:port>/package/foo/1.0.0


                          or..



                          dependencies: {
                          "foo": "http://<host:port>/package/foo/1.0.0"
                          }





                          share|improve this answer























                            up vote
                            7
                            down vote










                            up vote
                            7
                            down vote









                            I had this same problem, and after some searching around, I found Reggie (https://github.com/mbrevoort/node-reggie). It looks pretty solid. It allows for lightweight publishing of NPM modules to private servers. Not perfect (no authentication upon installation), and it's still really young, but I tested it locally, and it seems to do what it says it should do.



                            That is... (and this just from their docs)



                            npm install -g reggie
                            reggie-server -d ~/.reggie


                            then cd into your module directory and...



                            reggie -u http://<host:port> publish 
                            reggie -u http://127.0.0.1:8080 publish


                            finally, you can install packages from reggie just by using that url either in a direct npm install command, or from within a package.json... like so



                            npm install http://<host:port>/package/<name>/<version>
                            npm install http://<host:port>/package/foo/1.0.0


                            or..



                            dependencies: {
                            "foo": "http://<host:port>/package/foo/1.0.0"
                            }





                            share|improve this answer












                            I had this same problem, and after some searching around, I found Reggie (https://github.com/mbrevoort/node-reggie). It looks pretty solid. It allows for lightweight publishing of NPM modules to private servers. Not perfect (no authentication upon installation), and it's still really young, but I tested it locally, and it seems to do what it says it should do.



                            That is... (and this just from their docs)



                            npm install -g reggie
                            reggie-server -d ~/.reggie


                            then cd into your module directory and...



                            reggie -u http://<host:port> publish 
                            reggie -u http://127.0.0.1:8080 publish


                            finally, you can install packages from reggie just by using that url either in a direct npm install command, or from within a package.json... like so



                            npm install http://<host:port>/package/<name>/<version>
                            npm install http://<host:port>/package/foo/1.0.0


                            or..



                            dependencies: {
                            "foo": "http://<host:port>/package/foo/1.0.0"
                            }






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 16 '13 at 23:04









                            bwest87

                            960911




                            960911






















                                up vote
                                6
                                down vote













                                Structure your code in an accessible fashion like below. If this is possible for you.





                                • NodeProjsAppsMainApppackage.json


                                • NodeProjsModulesDataModulepackage.json





                                Within MainApp @ NodProjsAppsMainApp



                                npm install --S ../../Modules/DataModule


                                You may need to update package.json as:



                                 "dependencies": {
                                "datamodule": "../../Modules/DataModule"
                                }


                                This worked for my situation.






                                share|improve this answer

























                                  up vote
                                  6
                                  down vote













                                  Structure your code in an accessible fashion like below. If this is possible for you.





                                  • NodeProjsAppsMainApppackage.json


                                  • NodeProjsModulesDataModulepackage.json





                                  Within MainApp @ NodProjsAppsMainApp



                                  npm install --S ../../Modules/DataModule


                                  You may need to update package.json as:



                                   "dependencies": {
                                  "datamodule": "../../Modules/DataModule"
                                  }


                                  This worked for my situation.






                                  share|improve this answer























                                    up vote
                                    6
                                    down vote










                                    up vote
                                    6
                                    down vote









                                    Structure your code in an accessible fashion like below. If this is possible for you.





                                    • NodeProjsAppsMainApppackage.json


                                    • NodeProjsModulesDataModulepackage.json





                                    Within MainApp @ NodProjsAppsMainApp



                                    npm install --S ../../Modules/DataModule


                                    You may need to update package.json as:



                                     "dependencies": {
                                    "datamodule": "../../Modules/DataModule"
                                    }


                                    This worked for my situation.






                                    share|improve this answer












                                    Structure your code in an accessible fashion like below. If this is possible for you.





                                    • NodeProjsAppsMainApppackage.json


                                    • NodeProjsModulesDataModulepackage.json





                                    Within MainApp @ NodProjsAppsMainApp



                                    npm install --S ../../Modules/DataModule


                                    You may need to update package.json as:



                                     "dependencies": {
                                    "datamodule": "../../Modules/DataModule"
                                    }


                                    This worked for my situation.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Sep 14 '16 at 20:32









                                    wchoward

                                    1,5091924




                                    1,5091924






















                                        up vote
                                        3
                                        down vote













                                        Starting with arcseldon's answer, I found that the team name was needed in the URL like so:



                                        npm install --save "git+https://myteamname@aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myteamname/myprivate.git"


                                        And note that the API key is only available for the team, not individual users.






                                        share|improve this answer



























                                          up vote
                                          3
                                          down vote













                                          Starting with arcseldon's answer, I found that the team name was needed in the URL like so:



                                          npm install --save "git+https://myteamname@aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myteamname/myprivate.git"


                                          And note that the API key is only available for the team, not individual users.






                                          share|improve this answer

























                                            up vote
                                            3
                                            down vote










                                            up vote
                                            3
                                            down vote









                                            Starting with arcseldon's answer, I found that the team name was needed in the URL like so:



                                            npm install --save "git+https://myteamname@aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myteamname/myprivate.git"


                                            And note that the API key is only available for the team, not individual users.






                                            share|improve this answer














                                            Starting with arcseldon's answer, I found that the team name was needed in the URL like so:



                                            npm install --save "git+https://myteamname@aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4@bitbucket.org/myteamname/myprivate.git"


                                            And note that the API key is only available for the team, not individual users.







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited May 23 '17 at 10:31









                                            Community

                                            11




                                            11










                                            answered Aug 9 '16 at 19:26









                                            neonhomer

                                            32428




                                            32428






















                                                up vote
                                                2
                                                down vote













                                                Npm now provides unlimited private hosted modules for $7/user/month used like so



                                                cd private-project
                                                npm login


                                                in your package json set "name": " @username/private-project"



                                                npm publish


                                                then to require your project:



                                                cd ../new-project
                                                npm install --save @username/private-project





                                                share|improve this answer























                                                • Does this require a client-side login step?
                                                  – Aidan Hoolachan
                                                  Dec 16 '17 at 2:22










                                                • What's an alternative to this? For example, if you want to host your "package" on S3 and pull from there.
                                                  – Con Antonakos
                                                  Nov 27 at 22:19















                                                up vote
                                                2
                                                down vote













                                                Npm now provides unlimited private hosted modules for $7/user/month used like so



                                                cd private-project
                                                npm login


                                                in your package json set "name": " @username/private-project"



                                                npm publish


                                                then to require your project:



                                                cd ../new-project
                                                npm install --save @username/private-project





                                                share|improve this answer























                                                • Does this require a client-side login step?
                                                  – Aidan Hoolachan
                                                  Dec 16 '17 at 2:22










                                                • What's an alternative to this? For example, if you want to host your "package" on S3 and pull from there.
                                                  – Con Antonakos
                                                  Nov 27 at 22:19













                                                up vote
                                                2
                                                down vote










                                                up vote
                                                2
                                                down vote









                                                Npm now provides unlimited private hosted modules for $7/user/month used like so



                                                cd private-project
                                                npm login


                                                in your package json set "name": " @username/private-project"



                                                npm publish


                                                then to require your project:



                                                cd ../new-project
                                                npm install --save @username/private-project





                                                share|improve this answer














                                                Npm now provides unlimited private hosted modules for $7/user/month used like so



                                                cd private-project
                                                npm login


                                                in your package json set "name": " @username/private-project"



                                                npm publish


                                                then to require your project:



                                                cd ../new-project
                                                npm install --save @username/private-project






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Jun 3 '15 at 6:23

























                                                answered Jun 3 '15 at 6:11









                                                roo2

                                                4,59322138




                                                4,59322138












                                                • Does this require a client-side login step?
                                                  – Aidan Hoolachan
                                                  Dec 16 '17 at 2:22










                                                • What's an alternative to this? For example, if you want to host your "package" on S3 and pull from there.
                                                  – Con Antonakos
                                                  Nov 27 at 22:19


















                                                • Does this require a client-side login step?
                                                  – Aidan Hoolachan
                                                  Dec 16 '17 at 2:22










                                                • What's an alternative to this? For example, if you want to host your "package" on S3 and pull from there.
                                                  – Con Antonakos
                                                  Nov 27 at 22:19
















                                                Does this require a client-side login step?
                                                – Aidan Hoolachan
                                                Dec 16 '17 at 2:22




                                                Does this require a client-side login step?
                                                – Aidan Hoolachan
                                                Dec 16 '17 at 2:22












                                                What's an alternative to this? For example, if you want to host your "package" on S3 and pull from there.
                                                – Con Antonakos
                                                Nov 27 at 22:19




                                                What's an alternative to this? For example, if you want to host your "package" on S3 and pull from there.
                                                – Con Antonakos
                                                Nov 27 at 22:19










                                                up vote
                                                1
                                                down vote













                                                Config to install from public Github repository, even if machine is under firewall:



                                                dependencies: {
                                                "foo": "https://github.com/package/foo/tarball/master"
                                                }





                                                share|improve this answer

























                                                  up vote
                                                  1
                                                  down vote













                                                  Config to install from public Github repository, even if machine is under firewall:



                                                  dependencies: {
                                                  "foo": "https://github.com/package/foo/tarball/master"
                                                  }





                                                  share|improve this answer























                                                    up vote
                                                    1
                                                    down vote










                                                    up vote
                                                    1
                                                    down vote









                                                    Config to install from public Github repository, even if machine is under firewall:



                                                    dependencies: {
                                                    "foo": "https://github.com/package/foo/tarball/master"
                                                    }





                                                    share|improve this answer












                                                    Config to install from public Github repository, even if machine is under firewall:



                                                    dependencies: {
                                                    "foo": "https://github.com/package/foo/tarball/master"
                                                    }






                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Mar 4 '15 at 10:59









                                                    Alex Belozerov

                                                    38129




                                                    38129






















                                                        up vote
                                                        1
                                                        down vote













                                                        I use the following with a private github repository:



                                                        npm install github:mygithubuser/myproject





                                                        share|improve this answer

























                                                          up vote
                                                          1
                                                          down vote













                                                          I use the following with a private github repository:



                                                          npm install github:mygithubuser/myproject





                                                          share|improve this answer























                                                            up vote
                                                            1
                                                            down vote










                                                            up vote
                                                            1
                                                            down vote









                                                            I use the following with a private github repository:



                                                            npm install github:mygithubuser/myproject





                                                            share|improve this answer












                                                            I use the following with a private github repository:



                                                            npm install github:mygithubuser/myproject






                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered Feb 14 '17 at 20:58









                                                            Lars

                                                            8,27232332




                                                            8,27232332






















                                                                up vote
                                                                0
                                                                down vote













                                                                Very simple -



                                                                npm config set registry https://path-to-your-registry/


                                                                It actually sets registry = "https://path-to-your-registry" this line to /Users/<ur-machine-user-name>/.npmrc



                                                                All the value you have set explicitly or have been set by default can be seen by - npm config list






                                                                share|improve this answer



























                                                                  up vote
                                                                  0
                                                                  down vote













                                                                  Very simple -



                                                                  npm config set registry https://path-to-your-registry/


                                                                  It actually sets registry = "https://path-to-your-registry" this line to /Users/<ur-machine-user-name>/.npmrc



                                                                  All the value you have set explicitly or have been set by default can be seen by - npm config list






                                                                  share|improve this answer

























                                                                    up vote
                                                                    0
                                                                    down vote










                                                                    up vote
                                                                    0
                                                                    down vote









                                                                    Very simple -



                                                                    npm config set registry https://path-to-your-registry/


                                                                    It actually sets registry = "https://path-to-your-registry" this line to /Users/<ur-machine-user-name>/.npmrc



                                                                    All the value you have set explicitly or have been set by default can be seen by - npm config list






                                                                    share|improve this answer














                                                                    Very simple -



                                                                    npm config set registry https://path-to-your-registry/


                                                                    It actually sets registry = "https://path-to-your-registry" this line to /Users/<ur-machine-user-name>/.npmrc



                                                                    All the value you have set explicitly or have been set by default can be seen by - npm config list







                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited Jul 27 '17 at 9:05

























                                                                    answered Jul 11 '17 at 7:14









                                                                    sapy

                                                                    2,61922531




                                                                    2,61922531






















                                                                        up vote
                                                                        0
                                                                        down vote













                                                                        This was what I was looking for:



                                                                        # Get the latest from GitHub, public repo:
                                                                        $ npm install username/my-new-project --save-dev
                                                                        # Bitbucket, private repo:
                                                                        $ npm install git+https://token:x-oauth-basic@github.com/username/my-new-project.git#master
                                                                        $ npm install git+ssh://git@github.com/username/my-new-project.git#master

                                                                        # … or from Bitbucket, public repo:
                                                                        $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master --save-dev
                                                                        # Bitbucket, private repo:
                                                                        $ npm install git+https://username:password@bitbucket.org/username/my-new-project.git#master
                                                                        $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master
                                                                        # Or, if you published as npm package:
                                                                        $ npm install my-new-project --save-dev





                                                                        share|improve this answer

























                                                                          up vote
                                                                          0
                                                                          down vote













                                                                          This was what I was looking for:



                                                                          # Get the latest from GitHub, public repo:
                                                                          $ npm install username/my-new-project --save-dev
                                                                          # Bitbucket, private repo:
                                                                          $ npm install git+https://token:x-oauth-basic@github.com/username/my-new-project.git#master
                                                                          $ npm install git+ssh://git@github.com/username/my-new-project.git#master

                                                                          # … or from Bitbucket, public repo:
                                                                          $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master --save-dev
                                                                          # Bitbucket, private repo:
                                                                          $ npm install git+https://username:password@bitbucket.org/username/my-new-project.git#master
                                                                          $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master
                                                                          # Or, if you published as npm package:
                                                                          $ npm install my-new-project --save-dev





                                                                          share|improve this answer























                                                                            up vote
                                                                            0
                                                                            down vote










                                                                            up vote
                                                                            0
                                                                            down vote









                                                                            This was what I was looking for:



                                                                            # Get the latest from GitHub, public repo:
                                                                            $ npm install username/my-new-project --save-dev
                                                                            # Bitbucket, private repo:
                                                                            $ npm install git+https://token:x-oauth-basic@github.com/username/my-new-project.git#master
                                                                            $ npm install git+ssh://git@github.com/username/my-new-project.git#master

                                                                            # … or from Bitbucket, public repo:
                                                                            $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master --save-dev
                                                                            # Bitbucket, private repo:
                                                                            $ npm install git+https://username:password@bitbucket.org/username/my-new-project.git#master
                                                                            $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master
                                                                            # Or, if you published as npm package:
                                                                            $ npm install my-new-project --save-dev





                                                                            share|improve this answer












                                                                            This was what I was looking for:



                                                                            # Get the latest from GitHub, public repo:
                                                                            $ npm install username/my-new-project --save-dev
                                                                            # Bitbucket, private repo:
                                                                            $ npm install git+https://token:x-oauth-basic@github.com/username/my-new-project.git#master
                                                                            $ npm install git+ssh://git@github.com/username/my-new-project.git#master

                                                                            # … or from Bitbucket, public repo:
                                                                            $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master --save-dev
                                                                            # Bitbucket, private repo:
                                                                            $ npm install git+https://username:password@bitbucket.org/username/my-new-project.git#master
                                                                            $ npm install git+ssh://git@bitbucket.org/username/my-new-project.git#master
                                                                            # Or, if you published as npm package:
                                                                            $ npm install my-new-project --save-dev






                                                                            share|improve this answer












                                                                            share|improve this answer



                                                                            share|improve this answer










                                                                            answered Nov 20 at 7:27









                                                                            Isaiah

                                                                            165112




                                                                            165112






























                                                                                draft saved

                                                                                draft discarded




















































                                                                                Thanks for contributing an answer to Stack Overflow!


                                                                                • Please be sure to answer the question. Provide details and share your research!

                                                                                But avoid



                                                                                • Asking for help, clarification, or responding to other answers.

                                                                                • Making statements based on opinion; back them up with references or personal experience.


                                                                                To learn more, see our tips on writing great answers.





                                                                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                                Please pay close attention to the following guidance:


                                                                                • Please be sure to answer the question. Provide details and share your research!

                                                                                But avoid



                                                                                • Asking for help, clarification, or responding to other answers.

                                                                                • Making statements based on opinion; back them up with references or personal experience.


                                                                                To learn more, see our tips on writing great answers.




                                                                                draft saved


                                                                                draft discarded














                                                                                StackExchange.ready(
                                                                                function () {
                                                                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10386310%2fhow-to-install-a-private-npm-module-without-my-own-registry%23new-answer', 'question_page');
                                                                                }
                                                                                );

                                                                                Post as a guest















                                                                                Required, but never shown





















































                                                                                Required, but never shown














                                                                                Required, but never shown












                                                                                Required, but never shown







                                                                                Required, but never shown

































                                                                                Required, but never shown














                                                                                Required, but never shown












                                                                                Required, but never shown







                                                                                Required, but never shown







                                                                                Popular posts from this blog

                                                                                404 Error Contact Form 7 ajax form submitting

                                                                                How to know if a Active Directory user can login interactively

                                                                                TypeError: fit_transform() missing 1 required positional argument: 'X'