Solved: request 2.82.0 was updated to ES6 breaking npm install on old node

Just wanted to share my solution to a problem I encountered today.

The npm package request was updated to 2.82.0, introducing the requirement for ES6. Many packages depend on request and often have a loose requirement on the version, so they’ll silently upgrade to it when you run a new build. A telltale symptom of this type of failure is the following error message:

const Hoek = require('hoek');
Use of const in strict mode.

The solution is to pin down the version of request in your package.json to 2.81.0:

  "dependencies": {
    "request": "2.81.0"

This will cause npm to first download version 2.81.0, and then reuse that version for any package that asks for a version which overlaps 2.81.0.