Do you want to request a feature or report a bug?
Bug
What is the current behavior?
engines in package.json are ignore at least for node
If the current behavior is a bug, please provide the steps to reproduce.
package.json"engines": {
"node": ">=6.0.0 <7.0.0"
}
yarn What is the expected behavior?
Yarn won't success installing dependencies if node version doesn't match criteria
Please mention your node.js, yarn and operating system version.
OS: OS X El Capitan Version 10.11.6
Node: v4.4.7
Yarn: 0.21.3
The engines field gets only checked for dependencies of your package. So you can specify that your package runs on a range of node versions and other people installing your package will (hopefully) get a warning if they do so with a non-matching node version.
But it doesn't check the current node version against the engines field of _your_ application's package.json when installing its dependencies. I was confused with this as well but that's exactly how npm does it.
So if we strive for compatibility with npm, then this is currently not a bug. I still think it would be nice if we also checked against our own engines field. Don't see a reason why we wouldn't.
Ok, now I understand, even this behaviour also in npm is a bit confusing.
I'll prefer that before trying to fetch new modules yarn/npm will check your installed node (engines) against your module and then try to fetch dependencies.
But I if we strive for compatibility with npm, this behaviors must stay.
I'll like to behave like is done for yarn in yarn.js file that only node versions 4/5 are supported in here
Thanks
Recent versions of npm do check the engines field for your application (I know for sure going back to npm 4.4.1, but possibly earlier). I'm able to get npm install to fail as expected on an engine mismatch, but yarn install works. I'd consider this a bug if yarn is intended to be consistent with npm.
Just checked again with node v8.1.1, yarn v0.24.6, npm v5.0.3:
For both package managers, the engines field only concerns itself with dependencies of your module, not your module.
@bestander close; non-issue
Most helpful comment
Recent versions of npm do check the engines field for your application (I know for sure going back to npm 4.4.1, but possibly earlier). I'm able to get
npm installto fail as expected on an engine mismatch, butyarn installworks. I'd consider this a bug if yarn is intended to be consistent with npm.