JamieMason / ImageOptim-CLI

Make optimisation of images part of your automated build process
https://foldleft.io/image-tools
MIT License
3.45k stars 125 forks source link

Latest version can't be installed on NodeJS 20.x when setting engine-strict=true in ~/.npmrc #197

Closed henderea closed 10 months ago

henderea commented 1 year ago

Steps To Reproduce The Error

Add this to ~/.npmrc:

engine-strict=true

Then, using NodeJS version 20.x, try to install the latest version 3.1.7

Expected Behaviour

It installs successfully

Actual Behaviour

It claims the node version is unsupported

Version Numbers or N/A

Help Needed

Please update the engine section in the package.json to be greater than or equal to 18, rather than exactly 18. In other words, the value should be ">=18", not "^18.0.0".

Output of npm install -g imageoptim-cli@latest:

npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: imageoptim-cli@3.1.7
npm ERR! notsup Not compatible with your version of node/npm: imageoptim-cli@3.1.7
npm ERR! notsup Required: {"node":"^18.0.0"}
npm ERR! notsup Actual:   {"npm":"9.8.0","node":"v20.4.0"}

npm ERR! A complete log of this run can be found in: /Users/ehenderson/.npm/_logs/2023-07-11T16_41_09_238Z-debug-0.log

As a note, if you don't have engine-strict=true in your ~/.npmrc, things work fine. I just happen to normally use that setting.

If the package will only work on node 18 and up, I would recommend setting the following in the package.json:

"engineStrict": true,
"engines": {
  "node": ">=18"
},

By setting engineStrict to true in the package.json, you will block npm from installing the package on older versions even if the user doesn't set the property in their ~/.npmrc. Which would be almost everyone other than me 😅

If you don't set engineStrict to true in the package.json, then almost anyone would be able to install the latest version on NodeJS versions before 18, like 16 or 14. And I'm assuming that probably won't work well.

galenhuntington commented 10 months ago

Node 18 is in maintenance mode as of yesterday. So it seems prudent to loosen engines to allow Node 20.

JamieMason commented 10 months ago

Thanks all, should be an easy PR I'd be happy to merge.

JamieMason commented 10 months ago

Thanks @galenhuntington, released in https://github.com/JamieMason/ImageOptim-CLI/releases/tag/3.1.9