<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Justin Beckwith on Medium]]></title>
        <description><![CDATA[Stories by Justin Beckwith on Medium]]></description>
        <link>https://medium.com/@justinbeckwith?source=rss-32b3d805c3ba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Fuf3eD7Moc3ptgbt.jpg</url>
            <title>Stories by Justin Beckwith on Medium</title>
            <link>https://medium.com/@justinbeckwith?source=rss-32b3d805c3ba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:21:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@justinbeckwith/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[To lock or not to lock]]></title>
            <link>https://medium.com/@justinbeckwith/to-lock-or-not-to-lock-9ff7ec77e1ca?source=rss-32b3d805c3ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ff7ec77e1ca</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Justin Beckwith]]></dc:creator>
            <pubDate>Tue, 07 Jan 2020 15:37:22 GMT</pubDate>
            <atom:updated>2020-01-07T15:37:22.486Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*NeVeT4JSK8rCqxzbnfTLWw.png" /></figure><p>A few years ago, <a href="https://npmjs.org/">npm</a> introduced the notion of a <a href="https://docs.npmjs.com/files/package-lock.json">package-lock.json</a>. The purpose of the file is to provide a manifest that calls out the exact version of every package in your tree, the last time npm install was run. After running npm install, you&#39;re going to see a message like this:</p><p>npm notice created a lockfile as package-lock.json. You should commit this file.</p><p>While this advice is well intentioned… it’s not always true :) Let’s talk about when you want to check this into source control, and when not to.</p><h3>How package-lock.json works</h3><p>The mechanics of package-lock.json are simple enough:</p><ul><li>When you run npm install the first time, npm automatically creates the file for you.</li><li>It has the exact version of every top level and transitive dependency in your node_modules folder.</li><li>When you npm install some-package, the lock file is updated automatically.</li><li>When you update the version of a package in your package.json and run npm install, the package-lock.json file will get updated automatically.</li></ul><p>If you peek inside one of these files, you’re going to get a bunch of gobbledygook like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/752fc514343de9e6644b683b5fc8717b/href">https://medium.com/media/752fc514343de9e6644b683b5fc8717b/href</a></iframe><p>The next time you run npm install, you&#39;re (likely) going to get the exact copy of dependencies outlined in the package-lock.json file. If you didn&#39;t have a lock file, npm would look at every dependency in package.json, and find the latest compatible version of every top level and transitive dependency. Having a lock file saves you from this lookup on every install.</p><h3>Why lock files sound great</h3><p>In a world where lock files do not exist — running npm install is largely <a href="https://en.wikipedia.org/wiki/Idempotence">non-idempotent</a>, or non-reproducable. Given the same set of inputs, the outputs can be different. This means that I can run npm install twice, and the results in the node_modules folder can be wildly different. Stop me if you&#39;ve seen this happen before:</p><ul><li><em>I just wrote some code locally, and everything works</em></li><li><em>I go ahead and </em><em>git push my changes. For some reason CI is breaking!?</em></li><li><em>It’s a lint error… it looks like </em><em>prettier is failing on some formatting change</em>.</li></ul><p>This can happen because <strong>the version of </strong><strong>prettier you&#39;re using locally can be different than the version of </strong><strong>prettier you&#39;re getting in CI</strong>. This is one of the critical problems package lock files can solve - the version you&#39;re getting on your computer, and on CI are mostly going to be the same (there are exceptions for native modules, deleted package versions, etc).</p><p>Having an exact record of the full transitive dependency tree can be great for a few reasons:</p><ul><li>Every environment is (mostly) guaranteed to install the same set of dependencies when running npm install</li><li>npm install typically runs faster because some resolution steps can be skipped</li><li>There is a log in source control of the exact tree used to run your code and tests</li></ul><p>This all sounds great, but guess what … <em>I don’t use lock files, and if you’re building libraries, you probably shouldn’t use lock files either</em>.</p><h3>When lock files are not so great</h3><p>While lock files <em>sound</em> great, they come with some real baggage ranging from cosmetically annoying, to outright poor software practices. For context — my team at Google builds npm modules that other developers use to make their applications. In the context of a library, it does not make sense to use lock files (more on the end application use case later). <strong>We’ve broken far more customers specifically <em>because of our lock file usage</em>, and decided to start ignoring them across the ~80 or so npm modules we ship.</strong></p><h3>Generated files don’t belong in git</h3><p>The first reason I don’t like lock files is largely cosmetic. <em>I generally don’t like generated files to be tracked in source control</em>. I personally don’t like this for a few reasons:</p><ul><li>They create terrible merge conflicts</li><li>They make code reviews more difficult</li><li>Things like lock file maintenance PRs muddy commit history</li></ul><p>When dealing with PRs and trying to keep them up to date I just find the ergonomics… clunky.</p><h3>You’re not testing reality</h3><p>Way more importantly — <strong>lock files provide false comfort</strong>. You’re not testing what users get. The lock file you check into source control has no material impact on the module that developers will install. package-lock.json is not packaged into your module, and is not delivered to developers when they npm install your module. It is <em>only</em> used as a library developer, during local npm install for developer machines, and in CI.</p><p>In other words — The transitive dependencies that are defined in package-lock.json may not at all reflect what developers see when they run npm install. The transitive dependencies you test against in CI may not at all reflect what developers are seeing. You are probably testing against an entirely different set of dependencies than the ones developers will see.</p><p>Can you see how that’s a big problem? Here’s how it happens:</p><ol><li>You have a dependency on &quot;baby-yoda&quot;: &quot;^1.0.0&quot; in your package.json</li><li>baby-yoda@1.0.0 takes a dependency on green-lizard@1.0.0</li><li>You run npm install - at this point in time, green-lizard has its <a href="https://docs.npmjs.com/cli/dist-tag">dist-tag</a> set to 1.0.0, and that gets written into your package-lock.json</li><li>Your code, including the lock file, get checked into git</li></ol><p>So let’s stop, and take a breath. You installed the module baby-yoda, and you got a lock file that includes both baby-yoda@1.0.0 and green-lizard@1.0.0. All is going well! Let&#39;s say a few weeks pass...</p><ol><li>Somewhere over the last few weeks, green-lizard version 1.0.1 is released. It has a subtle breaking change that the authors missed (we ain&#39;t perfect).</li><li>Your nightly tests run, PRs are submited, and CI never notices there’s a problem with green-lizard@1.0.1. That&#39;s because you have green-lizard@1.0.0 in your package-lock.json, protecting you.</li><li>Consumers of your module are broken. They’re reporting errors related to the latest version of green-lizard, but you can&#39;t see the problem.</li><li>You delete your package-lock.json, run npm install, and all of the sudden you can reproduce the error.</li></ol><p>We’ve seen this dance play out several times. We want our nightly (and presubmit) CI to test against the same set of dependencies consumers of our libraries are going to see — and lock files make that impossible.</p><h3>When to use lock files, and when not to</h3><p>Lock files shine when you’re building <em>user facing applications</em>. If you’re building a web application, or command line tool (that isn’t npm install-ed), lock files protect you from the ever-changing set of transitive dependencies that make up your application. If your binary is packaging the node_modules folder along with your build, using a lock file is great. If you&#39;re building an npm module that you expect others to npm install - they aren&#39;t consumed by downstream users, and create more problems than they solve (in my opinion).</p><h3>How to ignore the lock file</h3><p>The easiest way to opt out of the lock file is to add the following to your .npmrc file:</p><p>There are a few approaches where you can find middle ground. One approach is to keep the lock file for the CI gains, but make sure to delete it as part of your nightly build workflow. This ensures CI builds are fast and consistent, but also gives you a warning when something goes awry. ( <a href="https://github.com/soldair">soldair</a> likes to call this the “broken every morning” approach). I personally don’t like the concept of nightly builds, but that’s a topic for another post.</p><h3>Some think differently, and that’s great!</h3><p>There are no “right” answers here. I don’t speak for every engineer working on node.js at Google :) Others like lock files, and believe the positives outweight the negatives. I’d love to know what you think! If you want to chat lock files, let me know at <a href="https://twitter.com/JustinBeckwith">@JustinBeckwith</a>!</p><p><em>Originally published at </em><a href="https://jbeckwith.com/2019/12/18/package-lock/"><em>https://jbeckwith.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ff7ec77e1ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Parse server to Google App Engine]]></title>
            <link>https://medium.com/google-cloud/deploying-parse-server-to-google-app-engine-6bc0b7451d50?source=rss-32b3d805c3ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bc0b7451d50</guid>
            <category><![CDATA[app-engine]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Justin Beckwith]]></dc:creator>
            <pubDate>Fri, 29 Jan 2016 07:10:55 GMT</pubDate>
            <atom:updated>2016-04-06T01:56:54.157Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*VHYGqjhONSJ20pRlIUbg7w.png" /></figure><p>Recently Parse announced they’re <a href="http://blog.parse.com/announcements/moving-on/">shutting down</a> their mobile backend as a service. If you’ve built an app on top of Parse, this is probably bad news. The good news is that they’re giving developers 12 months to find a new solution, and they’re providing a path to <a href="http://blog.parse.com/announcements/introducing-parse-server-and-the-database-migration-tool/">running your own</a> Parse-compatible service. There’s a great migration guide that covers <a href="https://parse.com/docs/server/guide">exporting Parse data</a> to MongoDB, and running a Parse server built on Node.js and express.</p><p>This guide is going to cover running the Parse server on <a href="http://cloud.google.com/nodejs">Google App Engine</a> and <a href="https://mongolab.com/google/">MongoLab</a>. You can learn about setting up parse and tons of other node.js apps on App Engine over at our <a href="https://cloud.google.com/nodejs/resources/frameworks/parse-server">node.js developer hub</a>.</p><h4>Set up a MongoLab database</h4><p>First, sign up for a <a href="https://mongolab.com/google/">MongoLab</a> account (if you don’t have one already).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4IsQCPTU9w4IM-nvVVAs0w.png" /></figure><p>When you get to the dashboard, create a new database:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*GJd5WUVOs-1D9xp9HRslwQ.png" /></figure><p>Make sure to select Google Cloud Platform as the cloud provider. I’m using the free tier to get started:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*TMHsD4hXfnJ_EzBYiXH5jQ.png" /></figure><p>After the database is available, click on the title in the dashboard. You need to create a user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAlqpCfR7lhOp9CwdA--7A.png" /></figure><p>Next, copy the connection string for the database. We’re going to use this in our node.js application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*escjGka1j4f8HVaU628OUA.png" /></figure><p>Now we have a database — let’s move onto the node.js app.</p><h4>Setting up Parse server</h4><p>The easiest way to get Parse server running on Google Cloud is to start with the sample out on <a href="https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git">GitHub</a>.</p><pre>git clone <a href="https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git">https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git</a><br>cd appengine/parse-server<br>npm install</pre><p>Now you need to setup a few config variables. Open up config.json, and set up the local config. You can learn more about the Parse config in the <a href="https://parse.com/docs/server/guide">migration guide</a>:</p><pre>{<br> “DATABASE_URI”: “mongodb://localhost:27017/dev”,<br> “CLOUD_PATH”: “./cloud/main.js”,<br> “APP_ID”: “&lt;your-app-id&gt;”,<br> “MASTER_KEY”: “&lt;your-master-key&gt;”,<br> “FILE_KEY”: “&lt;your-file-key&gt;”,<br> “PARSE_MOUNT_PATH”: “/parse”,<br> “SERVER_URL”: “&lt;your-server-url&gt;”<br>}</pre><p>That will help us run parse server locally. Now try it out:</p><pre>npm start</pre><p>Now lets deploy the app to App Engine!</p><h4>Deploy to Google App Engine</h4><p>Next we’re going to deploy the app to Google App Engine. If you get stuck, you can also follow the <a href="http://cloud.google.com/nodejs">node.js getting started guide.</a></p><p>Start by creating a project in the <a href="https://console.cloud.google.com/">Google Cloud Platform Console</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kW2y5W2SjZkowlJ7MriS8g.png" /></figure><p>Next, <a href="https://console.cloud.google.com/project/_/settings">enable billing</a>. You can run applications on App Engine Managed VMs with the free trial.</p><p>Install the <a href="https://cloud.google.com/sdk/">Google Cloud SDK</a>. Run `gcloud init` and sign in with your Google account. Finally — deploy your app:</p><pre>gcloud preview app deploy</pre><p>When the deployment is done, navigate t0 <a href="http://%3Cyour-app-id%3E.appspot.com">http://&lt;your-app-id&gt;.appspot.com</a> and check it out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*i48Qt4-r_pfxa1HN_00CXw.png" /></figure><p>And you’re set. To learn more about running node.js applications on Google cloud, check out our <a href="http://cloud.google.com/nodejs">docs</a>, or take a look at our other <a href="http://github.com/GoogleCloudPlatform/nodejs-docs-samples">samples on GitHub. </a>Let us know what you think!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bc0b7451d50" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/deploying-parse-server-to-google-app-engine-6bc0b7451d50">Deploying Parse server to Google App Engine</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>