{"id":651,"date":"2018-10-11T09:20:23","date_gmt":"2018-10-11T13:20:23","guid":{"rendered":"http:\/\/jasonralph.org\/?p=651"},"modified":"2018-10-11T09:20:52","modified_gmt":"2018-10-11T13:20:52","slug":"sinopia-npm-allow-connections-to-github-as-well-as-the-npm-registry","status":"publish","type":"post","link":"https:\/\/jasonralph.org\/?p=651","title":{"rendered":"SINOPIA NPM allow connections to GITHUB as well as the NPM registry"},"content":{"rendered":"<p><a href=\"https:\/\/www.npmjs.com\/package\/sinopia\">SINOPIA LINK HERE<\/a><br \/>\nWe use SINOPIA as a proxy on our internal network behind the firewall to allow users to install NODE packages without an internet connection.  We basically run sinopia on a machine that has access to the internet and the clients point to the server to install packages that are not locally available.  We have been running into issues where installs that needed access to github would fail with something like this:<\/p>\n<pre class=\"theme:solarized-dark lang:default decode:true \" >\r\n[15:29:07] user1@sb-user1:~\/app\/mc_api\/lib\/reports $ npm install --save slack\/client --loglevel verbose\r\nnpm info it worked if it ends with ok\r\nnpm verb cli [ '\/home\/user1\/node_local_install\/.nvm\/versions\/node\/v8.9.4\/bin\/node',\r\nnpm verb cli   '\/home\/user1\/node_local_install\/.nvm\/versions\/node\/v8.9.4\/bin\/npm',\r\nnpm verb cli   'install',\r\nnpm verb cli   '--save',\r\nnpm verb cli   'slack\/client',\r\nnpm verb cli   '--loglevel',\r\nnpm verb cli   'verbose' ]\r\nnpm info using npm@6.4.1\r\nnpm info using node@v8.9.4\r\nnpm verb npm-session f40f30f7bf0339f9\r\nnpm timing stage:rollbackFailedOptional Completed in 1ms\r\nnpm timing stage:runTopLevelLifecycles Completed in 1114ms\r\nnpm verb stack Error: exited with error code: 128\r\nnpm verb stack     at ChildProcess.<anonymous> (\/home\/user1\/node_local_install\/.nvm\/versions\/node\/v8.9.4\/lib\/node_modules\/npm\/node_modules\/pacote\/lib\/util\/finished.js:12:19)\r\nnpm verb stack     at emitTwo (events.js:126:13)\r\nnpm verb stack     at ChildProcess.emit (events.js:214:7)\r\nnpm verb stack     at maybeClose (internal\/child_process.js:925:16)\r\nnpm verb stack     at Socket.stream.socket.on (internal\/child_process.js:346:11)\r\nnpm verb stack     at emitOne (events.js:116:13)\r\nnpm verb stack     at Socket.emit (events.js:211:7)\r\nnpm verb stack     at Pipe._handle.close [as _onclose] (net.js:554:12)\r\nnpm verb cwd \/home\/user1\/app\/mc_api\/lib\/reports\r\nnpm verb Linux 2.6.32-754.3.5.el6.x86_64\r\nnpm verb argv \"\/home\/user1\/node_local_install\/.nvm\/versions\/node\/v8.9.4\/bin\/node\" \"\/home\/user1\/node_local_install\/.nvm\/versions\/node\/v8.9.4\/bin\/npm\" \"install\" \"--save\" \"slack\/client\" \"--loglevel\" \"verbose\"\r\nnpm verb node v8.9.4\r\nnpm verb npm  v6.4.1\r\nnpm ERR! Error while executing:\r\nnpm ERR! \/usr\/bin\/git ls-remote -h -t ssh:\/\/git@github.com\/slack\/client.git\r\nnpm ERR!\r\nnpm ERR! ssh: connect to host github.com port 22: Connection refused\r\nnpm ERR! fatal: Could not read from remote repository.\r\nnpm ERR!\r\nnpm ERR! Please make sure you have the correct access rights\r\nnpm ERR! and the repository exists.\r\nnpm ERR!\r\nnpm ERR! exited with error code: 128\r\nnpm verb exit [ 1, true ]\r\nnpm timing npm Completed in 1497ms\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR!     \/home\/user1\/.npm\/_logs\/2018-10-10T19_34_06_306Z-debug.log\r\n<\/pre>\n<p>As you can see, we are getting choked at:<\/p>\n<pre class=\"theme:solarized-dark lang:default decode:true \" >\r\nnpm ERR! ssh: connect to host github.com port 22: Connection refused\r\nnpm ERR! fatal: Could not read from remote repository.\r\n<\/pre>\n<p>To get around this we need to change the config.yml on the server to allow proxies to github, here is the final configuration.  Hope this helps other users as we had a fun time trying to figure it out. Pay attention to the uplinks section and the proxy requests where github is defined. <\/p>\n<pre class=\"theme:solarized-dark lang:default decode:true \" >\r\n#\r\n# This is the default config file. It allows all users to do anything,\r\n# so don't use it on production systems.\r\n#\r\n# Look here for more config file examples:\r\n# https:\/\/github.com\/rlidwka\/sinopia\/tree\/master\/conf\r\n#\r\n\r\n# path to a directory with all packages\r\nstorage: .\/storage\r\n\r\nauth:\r\n  htpasswd:\r\n    file: .\/htpasswd\r\n    # Maximum amount of users allowed to register, defaults to \"+inf\".\r\n    # You can set this to -1 to disable registration.\r\n    #max_users: 1000\r\n\r\n# a list of other known repositories we can talk to\r\nuplinks:\r\n  npmjs:\r\n    url: https:\/\/registry.npmjs.org\/\r\n  github:\r\n    url: https:\/\/github.com\/\r\n\r\npackages:\r\n  '@*\/*':\r\n    # scoped packages\r\n    access: $all\r\n    publish: $authenticated\r\n    proxy:\r\n      - npmjs\r\n      - github\r\n\r\n\r\n  '*':\r\n    # allow all users (including non-authenticated users) to read and\r\n    # publish all packages\r\n    #\r\n    # you can specify usernames\/groupnames (depending on your auth plugin)\r\n    # and three keywords: \"$all\", \"$anonymous\", \"$authenticated\"\r\n    access: $all\r\n\r\n    # allow all known users to publish packages\r\n    # (anyone can register by default, remember?)\r\n    publish: $authenticated\r\n\r\n    # if package is not available locally, proxy requests to 'npmjs' registry\r\n    proxy:\r\n      - npmjs\r\n      - github\r\n# log settings\r\nlogs:\r\n  #- {type: stdout, format: pretty, level: http}\r\n  - {type: file, path: sinopia.log, level: debug}\r\n\r\n#Bind Address\r\nlisten:\r\n  - 0.0.0.0:4873\r\n#\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SINOPIA LINK HERE We use SINOPIA as a proxy on our internal network behind the firewall to allow users to install NODE packages without an internet connection. We basically run sinopia on a machine that has access to the internet and the clients point to the server to install packages that are not locally available. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,1],"tags":[64,65,67,66],"class_list":["post-651","post","type-post","status-publish","format-standard","hentry","category-coding-thoughts","category-general-code","tag-node","tag-npm","tag-proxy","tag-sinopia"],"_links":{"self":[{"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/posts\/651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jasonralph.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=651"}],"version-history":[{"count":6,"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/posts\/651\/revisions"}],"predecessor-version":[{"id":669,"href":"https:\/\/jasonralph.org\/index.php?rest_route=\/wp\/v2\/posts\/651\/revisions\/669"}],"wp:attachment":[{"href":"https:\/\/jasonralph.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jasonralph.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jasonralph.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}