How We Use npm At uShip
Here at the ‘Ship we don’t actually run a node server in production, we just use node for our front-end build system. This includes transpiling our SCSS to CSS, transpiling our ECMAScript 6 to ECMAScript 5, linting, and most recently, bundling via webpack.
Our Old Way of Doing Things
Limitations/Issues We Came Across
The first problem we encountered was the length of file paths for deeply-nested dependencies. Windows has problems with file paths longer than 260 characters, thus, if any dependencies had file paths in our node_modules folder that were longer than that, then we weren’t able to commit our dependencies. Our solution was to use a package called flatten-deps which moved all of our nested dependencies to the root of the node_modules directory. This worked well, but required us to rerun the flattening process with every change to our dependencies.. We ignored this annoyance for a while, though, since there was no better solution.
Our Transition to npm On-Site
npm Enterprise
We struggled to get npm Enterprise functioning properly at first due to our version of npm being out of date. After we fixed this, we still ran into problems with the original initialization of the registry while it scanned the entire public registry for an initial pass. We still don’t fully understand why, but it stopped in the middle and never finished. After talking with support, they recommended that we try out anew version of npm Enterprise more suited to our needs.. They call this new version npm On-Site.
How npm On-Site Is Different
Final Impressions
Now, in order to add a new dependency we only have to execute two steps. First, ssh into our On-Site server. Second, install the desired dependency which in turn whitelists that dependency’s required dependencies. This has completely transformed how we manage our dependencies and made our process much simpler. So far it has been working great aside from a small nuance I ran into one time where a package randomly started 404’ing. In that case, though, it was plenty easy to log into the On-Site server and add the missing package and things went right back to normal.