Ask Your Question
0

[Tox] npm gives URLError

asked 2017-07-23 20:07:07 -0500

anonymous user

Anonymous

Hi,

I have started using DevStack recently and while running tox -e npm on /opt/stack/horizon, the following error is displayed:

Traceback (most recent call last):
  File "/opt/stack/horizon/.tox/npm/bin/nodeenv", line 11, in <module>
    sys.exit(main())
  File "/opt/stack/horizon/.tox/npm/local/lib/python2.7/site-packages/nodeenv.py", line 1019, in main
    opt.node = get_last_stable_node_version()
  File "/opt/stack/horizon/.tox/npm/local/lib/python2.7/site-packages/nodeenv.py", line 953, in get_last_stable_node_version
    response = urlopen('https://%s/dist/latest/' % (src_domain))
  File "/opt/stack/horizon/.tox/npm/local/lib/python2.7/site-packages/nodeenv.py", line 557, in urlopen
    return urllib2.urlopen(req)
  File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1241, in https_open
    context=self._context)
  File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -5] No address associated with hostname>

The URL 'https://%s/dist/latest/' % (src_domain) points to https://nodejs.org/dist/latest/ and running curl https://nodejs.org/dist/latest/ does not result in the same issue.

I believe similar questions had been asked online but none of them seem to provide a good answer to this. Does anybody know a solution to this problem?

Regards

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-24 20:47:20 -0500

yeexinc gravatar image

updated 2017-07-24 20:49:26 -0500

The problem was that I was working behind a proxy.

I added the following codes in the urlopen(url) function:

def urlopen(url):
      home_url = "https://github.com/ekalinin/nodeenv/"

      proxy = urllib2.ProxyHandler({'https' : 'http://example@proxywebsite:proxyport/'})
      opener = urllib2.build_opener(proxy)
      urllib2.install_opener(opener)

      headers = {'User-Agent': 'nodeenv/%s (%s)' % (nodeenv_version, home_url     )}
      req = urllib2.Request(url, None, headers)
      return urllib2.urlopen(req)

Based on this answer: https://stackoverflow.com/questions/1450132/proxy-with-urllib2 (https://stackoverflow.com/questions/1...)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2017-07-23 20:07:07 -0500

Seen: 49 times

Last updated: Jul 24 '17