krakenjs / kappa

A hierarchical npm-registry proxy
Other
557 stars 56 forks source link

Question: NPM CLI setup for Kappa #108

Closed program247365 closed 9 years ago

program247365 commented 9 years ago

I'm probably a complete noob, but, what am I missing here? Am I missing that I need to setup a registry backing Kappa? https://github.com/rvagg/npmjs.org/blob/6793c71165934423f1989f54a754a6691a94f3b0/README.md

On the Kappa instance itself, I can

npm --registry=http://localhost:8000 install lodash

And I at least see in the running Kappa instance, it 404 on this request.

150506/195745.123, request, http://localhost:8000: get /lodash {} 404 (9ms)

If I try on my local machine...

npm set registry http://my-kappa-box.mynetwork.com:8000 install request
npm install

Error log

$ npm install
npm WARN package.json myproject@1.0.114 No description
npm WARN package.json myproject@1.0.114 No repository field.
npm WARN package.json myproject@1.0.114 No README data
npm ERR! Error: connect ECONNREFUSED
npm ERR!     at errnoException (net.js:904:11)
npm ERR!     at Object.afterConnect [as oncomplete] (net.js:895:19)
npm ERR!  { [Error: connect ECONNREFUSED]
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   syscall: 'connect',
npm ERR!   parent: 'synacor-application-fe-primetime-assets' }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly.  See: 'npm help config'

npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/kridgway/Code/myproject
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! syscall connect
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! stack Error: connect ECONNREFUSED
npm ERR! stack     at errnoException (net.js:904:11)
npm ERR! stack     at Object.afterConnect [as oncomplete] (net.js:895:19)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/kridgway/Code/myproject/npm-debug.log
npm ERR! not ok code 0

Further, once I figure out my issue, is there a way to set in our package.json for the myproject we're working on, so that whenever you 'npm install', within the project that has package.json, it will always try our local kappa instance? Or does a person always have to 'npm set registry' first?

Any help is appreciated for helping me understand the setup end-to-end.

aredridel commented 9 years ago

Not actual fixes, but some things I notice:

jasisk commented 9 years ago

Kappa is just the “intelligent” proxy. Your config should have something like the following:

{
  // ... snip ...
    "plugins": {
        "kappa": {
            "vhost": null,
            "paths": [
                "http://localhost:5984/registry/_design/scratch/_rewrite/",
                "https://registry.npmjs.org/"
            ]
        }
    }
  // ... snip ...
}

You'll find a similar structure in the example project.

You'll need to have the npm couchapp up and running locally, in that example. You could do without it just to make sure kappa is working by just having an array with the public registry in it.

If you want to set up the couchapp, it's a bit painful, but we've got a shell script that will get you most of the way there (the ini is there, too).

Lastly, while there is nothing you can set in a package.json to define the registry, you can thrown an .npmrc file in the root of a project with the registry key defined and it'll do what you want.

jasisk commented 9 years ago

Closing this due to inactivity but feel free to continue the conversation if necessary. :grinning:

program247365 commented 9 years ago

Sorry all, got pulled away on other things.

@jasisk

Lastly, while there is nothing you can set in a package.json to define the registry, you can thrown an .npmrc file in the root of a project with the registry key defined and it'll do what you want.

Thank you! Needed that.

Ah ok, wasn't clear to me that couchdb was the backing store from the README of kappa, etc. (no mention of it) Perhaps if one had setup a local npm registry before, maybe that would have been obvious. Perhaps a good place to mention such a thing?

I may look at some of the other projects that setup a npm registry for you in one fell swoop (either by npm install, or docker container).

@aredridel Thank you for pointing those things out!

You guys were awesome. Thanks!

jasisk commented 9 years ago

Perhaps a good place to mention such a thing?

Good point. I'll add it.

I may look at some of the other projects that setup a npm registry for you in one fell swoop (either by npm install, or docker container).

@terinjokes was maintaining a docker image for kappa, and then a vanilla couchapp image. Not sure he still is, but that should prove a good foundation if you want to go that route.

You guys were awesome. Thanks!

Happy to help. :grinning:

terinjokes commented 9 years ago

While I'm not currently maintaining a Docker image, getting it right is hard, and at the time, Docker's networking stack didn't do what I wanted, eventually I'll get back to it. In the meantime, I'm happy to answer questions.