{"id":1482,"date":"2015-10-30T04:31:32","date_gmt":"2015-10-30T11:31:32","guid":{"rendered":"http:\/\/10kdev.net\/?p=1482"},"modified":"2015-10-30T11:29:32","modified_gmt":"2015-10-30T18:29:32","slug":"its-in-npm-somewhere-it-must-be","status":"publish","type":"post","link":"http:\/\/10kdev.net\/?p=1482","title":{"rendered":"It&#8217;s in npm <i>somewhere<\/i> . . . it must be."},"content":{"rendered":"<div style=\"width: 531px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/10kdev.net\/wp-content\/uploads\/2015\/10\/f5ed0cda5f1004f08f367bfe906aa7b2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"\" src=\"http:\/\/10kdev.net\/wp-content\/uploads\/2015\/10\/f5ed0cda5f1004f08f367bfe906aa7b2.png\" alt=\"\" width=\"521\" height=\"102\" \/><\/a><p class=\"wp-caption-text\">&#8220;Package versions? As many as there are stars in the sky.&#8221; &#8211; Dances with Dependencies<\/p><\/div>\n<p>I&#8217;m sure many developers have been finding nodejs buried in pretty much everything these days, and that can mean dependency management with npm and package.json. \u00a0And more often than not I am finding version collisions and dependency needs unmet in non-trivial and time draining situations.<\/p>\n<p>Working on a large commerce engine, <strong>it fell to my shoulders to do a minor version upgrade<\/strong>.<\/p>\n<p>Versioning on <em>some<\/em>\u00a0pieces have been very discrete: JDK7 (for now), Ruby 2.2.2; jstl 1.2 libraries and specific jdbc drivers. \u00a0The vendor \u00a0ignored specifying versions and &#8220;get the latest greatest&#8221; rules the roost for ruby gem packages and nodejs. \u00a0So far the who-cares-what-version gems have not been a problem (but \u00a0they *will* be, can almost guarantee it). \u00a0Other packages needed for node aren&#8217;t specified in package.json, allowing for the pull of the latest-greatest as well.<\/p>\n<p>I have a few setup tasks, then to run \u00a0<strong>npm install<\/strong> \u00a0in the project to pull the node modules, then do <strong>gradle build<\/strong>. \u00a0We can run it from there.<\/p>\n<p>First the vanilla try: I run npm install, then gradle build &#8212; breakage on the build:<\/p>\n<p style=\"padding-left: 30px;\"><em>Running &#8220;sass:dev&#8221; (sass) task\u00a0&gt;&gt; (base: #CE1A2B, light: #e63546, dark: #a11422) isn&#8217;t a valid CSS value.<\/em><\/p>\n<p>Working with two other team members, I got a hint: we needed to specify a version, decided by magic (trial and error) in package.json, a dependency entry:<\/p>\n<pre style=\"padding-left: 30px;\">\"node-sass\":\"3.2.0\"<\/pre>\n<p>That fixed some problems with our EXISTING builds; this breakage was intermittent and now in hindsight I am guessing due to a race condition of node-sass dependency pulls; get lucky and the right version wins. \u00a0We propagate the fix to the repository.<\/p>\n<p>But for the minor version upgrade I was working on? \u00a0Didn&#8217;t work. \u00a0Running npm install\u00a0would generate an error:<\/p>\n<p style=\"padding-left: 30px;\"><em>Cannot download &#8220;https:\/\/github.com\/sass\/node-sass\/releases\/download\/v3.2.0\/win32-x64-46_binding.node&#8221;<\/em><\/p>\n<p>Digging through github to see their releases, well,\u00a0there is<a href=\"https:\/\/github.com\/sass\/node-sass\/releases\/tag\/v3.2.0\"> no minor version of -46 for node-sass 3.2.0<\/a>. \u00a0The newest version being 3.4.1 right now &#8212; but that version (pulling latest-greatest method, our initial methodology problem) which has a -46 breaks the build due to the css error mentioned above. \u00a0Another very strange thing is that no matter what version I put in, it asks for the -46 rendition; as if when I specify a version in package.json it only parses teh x.x.x part, but doesn&#8217;t allow for me to specify the -xx version part.<\/p>\n<p>Running\u00a0<strong>npm install &#8211;dev<\/strong>\u00a0 was a huge mistake as it pulled the universe down and still broke; \u00a0when I went to delete the node_modules directory there were really long file paths that Windows hates to delete. \u00a0I had to rename tons of recursive folders to &#8220;a&#8221;. \u00a0Cost me at least an hour to bail out of that route.<\/p>\n<p>So I started to climb through the repository for node-sass up from 3.2.0, and found\u00a0a 46 release for version 3.3.3. \u00a0I tried that, and it worked and built. \u00a0I don&#8217;t know why, I can&#8217;t generate a legible dependency tree or run a dry run with npm-install.<\/p>\n<p>It&#8217;s disconcerting though &#8212; why 3.3.3 other than it has a -46 rendition? \u00a0There&#8217;s no vendor explanation. And only a long regression test will say if it really works. \u00a0I talked with the local nodejs expert and asked questions about the type of dry-run I&#8217;d like to do with npm (from what I understand, and how to get a dependency graph and figure out what version I need &#8212; this is the next step to line up with the regression tests.<\/p>\n<p>Specifying package versions seem to have a shortcoming, in my opinion, as well. \u00a0 This <a href=\"http:\/\/blog.nodejitsu.com\/package-dependencies-done-right\/\">article from nodejitsu does a great job at discussing semantic package naming<\/a>, but there doesn&#8217;t seem to be a way to specify my -46 release and the article kind of confirms that (I tried every syntax under the sun). \u00a0Here is the <a href=\"https:\/\/docs.npmjs.com\/files\/package.json\">syntax for\u00a0package.json<\/a>, my situation concerned with dependencies, \u00a0and I tried different things without success. \u00a0For instance specifying &#8220;~3.2.1&#8221; which is an approximate-equivalent provided a successful npm install, but not a successful gradle build.<\/p>\n<p>The npm system isn&#8217;t quite as mature as say maven but it is making leaps because people like you and I are coming in with experience on different systems and use cases to contribute. \u00a0For now though, I have to dig down into the dependency graphs even further, and better yet, ask the vendor to list versions of packages it needs for its software instead of assuming the latest-greatest will always work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m sure many developers have been finding nodejs buried in pretty much everything these days, and that can mean dependency management with npm and package.json. \u00a0And more often than not I am finding version collisions and dependency needs unmet in non-trivial and time draining situations. Working on a large commerce engine, it fell to my [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[69,82],"tags":[85],"_links":{"self":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/1482"}],"collection":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1482"}],"version-history":[{"count":11,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/1482\/revisions"}],"predecessor-version":[{"id":1493,"href":"http:\/\/10kdev.net\/index.php?rest_route=\/wp\/v2\/posts\/1482\/revisions\/1493"}],"wp:attachment":[{"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1482"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10kdev.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}