Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
henderea opened this issue Jul 11, 2023 · 3 comments

Comments

@henderea
Copy link

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.

@galenhuntington
Copy link
Contributor

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

@JamieMason
Copy link
Owner

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

@JamieMason
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants