Skip to content

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

@henderea

Description

@henderea

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

  • macOS: 12.6.7
  • NodeJS: 20.4.0
  • /Applications/ImageOptim.app: 1.8.8
  • /Applications/ImageAlpha.app: Not sure, but it isn't relevant
  • /Applications/JPEGmini.app: not installed

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions