cloudfour/lighthouse-parade

Deal with Node version requirements

emersonthis opened this issue · 2 comments

We developed this tool using Node 14. It probably works in other versions, but 🤷 .

  • Test in other popular Node versions
  • Update README install instructions to include which versions of Node are compatible.
  • Consider adding a check / warning to the script if it's run with a different version?

I looked at how several popular packages are handling this. I tried installing Jest and Prettier globally on node 8:

$ npm i -g prettier

/Users/calebeby/.config/nvm/8.17.0/bin/prettier -> /Users/calebeby/.config/nvm/8.17.0/lib/node_modules/prettier/bin-prettier.js
npm WARN notsup Unsupported engine for prettier@2.1.2: wanted: {"node":">=10.13.0"} (current: {"node":"8.17.0","npm":"6.13.4"})
npm WARN notsup Not compatible with your version of node/npm: prettier@2.1.2

+ prettier@2.1.2
added 1 package from 1 contributor in 0.328s

So the package installed successfully, but a clear message appears saying that it is not compatible

Then if I try to run it it doesn't work:

$ prettier -v

/Users/calebeby/.config/nvm/8.17.0/lib/node_modules/prettier/third-party.js:9871
      for await (const place of this.config.searchPlaces) {
          ^^^^^

SyntaxError: Unexpected reserved word

Jest is basically the same:

$ npm i -g jest
/Users/calebeby/.config/nvm/8.17.0/bin/jest -> /Users/calebeby/.config/nvm/8.17.0/lib/node_modules/jest/bin/jest.js
npm WARN notsup Unsupported engine for jest@26.4.2: wanted: {"node":">= 10.14.2"} (current: {"node":"8.17.0","npm":"6.13.4"})
npm WARN notsup Not compatible with your version of node/npm: jest@26.4.2

... and a bunch more errors saying the same thing, but for jest's dependencies

+ jest@26.4.2
added 506 packages from 348 contributors in 16.911s
$ jest -v

/Users/calebeby/.config/nvm/8.17.0/lib/node_modules/jest/node_modules/jest-cli/build/cli/index.js:227
    } catch {
            ^

SyntaxError: Unexpected token {

These packages use the package.json engines field so that npm will give a warning if the package is installed on an unsupported node version.

I added the same thing a few PR's back so we should be all set. I will open up a follow-up PR so that the tests run on both node 12 and 14.

Great.