Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mimosa mod:list not working behind Proxy #293

Closed
Anachron opened this issue Oct 11, 2013 · 11 comments · Fixed by #300
Closed

Mimosa mod:list not working behind Proxy #293

Anachron opened this issue Oct 11, 2013 · 11 comments · Fixed by #300

Comments

@Anachron
Copy link
Contributor

Mimosas mod:list doesn't work behind proxy and returns following error:
node\node_modules\mimosa\node_modules\mimosa-bower\node_modules\bow
er\node_modules\tmp\lib\tmp.js:261
throw err;
^
Error: connect ENETUNREACH
at errnoException (net.js:901:11)
at Object.afterConnect as oncomplete

Hower, using mimosa mod:install xyz you can still install modules.

I already set NPM proxy with npm config set (https-)proxy & github-proxy using the gitconfig-file.

@dbashford
Copy link
Owner

Probably should use request for this. The module. Rather than trying to navigate proxy issues myself.

@Anachron
Copy link
Contributor Author

I was just thinking, you could grab the proxy from with "npm config get proxy" and use it like this in a http-request
http://stackoverflow.com/a/6781592

You could either cache the proxy or read it everytime.

@dbashford
Copy link
Owner

Can you try something for me?

In a folder run npm install request.

Then pull in this code: https://gist.github.com/dbashford/a7b30f8743354dd47cb1, toss it in test.js and run node test.js.

What do you get?

@Anachron
Copy link
Contributor Author

I got the following response:

{pathToNode}\node>node test.js
{ [Error: connect ENETUNREACH] code: 'ENETUNREACH', errno: 'ENETUNREACH', syscal
l: 'connect' }

TypeError: Cannot read property 'statusCode' of undefined
at Request._callback ({pathToNode}\node\test.js:7:24)
at self.callback ({pathToNode}\node\node_modules\request\request.js:129:22)
at Request.EventEmitter.emit (events.js:95:17)
at ClientRequest.self.clientErrorHandler ({pathToNode}\node\node_modules\req
uest\request.js:239:10)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1517:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)

Edit:
{pathToNode}\node>npm request -v
1.3.1

What do you think about my solution?

@dbashford
Copy link
Owner

I'd have to see how that solution worked. Unfortunately I'm not behind a proxy so it would be hard for me to code and test properly.

What does npm config get proxy return for you?

@Anachron
Copy link
Contributor Author

{pathToNode}\node>npm config get proxy
http://182.64.136.201:1954/

You have to set this accordingly to this:
https://npmjs.org/doc/config.html
https://npmjs.org/doc/misc/npm-config.html#proxy

It defaults to HTTP_PROXY (http_proxy), but can be set specifically (for Windows restricted cases, for example).

@dbashford
Copy link
Owner

To be honest, the best option is to just build a web app that showcases the modules rather than have a command for it. I'd either nuke the command or have the command just launch the app in their default browser. I just haven't gotten around to that.

Given that the modules are listed on the website and that I'd rather have a specific UI for this as the final solution, I'm reluctant to take this on. I'd merge it as a PR, but if I were to address this right now I'd rather place some proper error messaging in to catch this case (and redirect to the list on the website) and wait until I get time for the other solutions.

@Anachron
Copy link
Contributor Author

I didn't quite understand my ToDo in here. The thing you have to care about in your modules are the proxies that the user may want to use. In either case, "npm config get proxy" and "npm config get https-proxy" return the protocol, the IP (or domain) and the port (can contain user/password as well). It should be wrapped in a regex and be split accordingly.

I think having a command is good too, you could even support paging. (I am a fan of cli)
However, a website would be good to go too!

@Anachron
Copy link
Contributor Author

Is there any news on this? It's good that you noticed the users about this problem for starters. But I am still wondering, if you could grab the response to "npm config get proxy" and run a regex over it, so you extract the required data that you fill in optionally into the request options.

@dbashford
Copy link
Owner

This fix will get slotted from a priority perspective behind some other things I'm doing right now. I understand what you are explaining. I'd love to see an example of someone using this method to solve this problem since I feel like the problem is one you'd encounter often.

@Anachron
Copy link
Contributor Author

Here is the update. This is a small gist I used to read npm configuration and read all of your modules.
https://gist.github.com/Anachron/7004957

This gist is tested behind a corporate proxy.

Edit2: I fixed the problem with linefeed after stdout.
After testing with and without proxy, those modules now always seem to load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants