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

How to handle invalid engines #1102

Closed
kevinastone opened this issue Oct 15, 2016 · 14 comments
Closed

How to handle invalid engines #1102

kevinastone opened this issue Oct 15, 2016 · 14 comments

Comments

@kevinastone
Copy link

Similar to #1003

Do you want to request a feature or report a bug?

Bug

Fix: Add atom to:

'rhino', // once a target for older modules

@sebmck
Copy link
Contributor

sebmck commented Oct 15, 2016

I don't think we should suppress this. Atom is quite new so existing libraries should update themselves to remove the engine as we're correctly enforcing this. In the future this warning may be a hard error.

@sebmck sebmck closed this as completed Oct 15, 2016
@kevinastone
Copy link
Author

kevinastone commented Oct 15, 2016

I'm confused. Atom uses the engines field to specify the compatible version of Atom for a given package. Is Atom not supposed to use the engines field? Is there an issue on Atom to change this?

@sebmck
Copy link
Contributor

sebmck commented Oct 15, 2016

I guess this calls into question about why we report on invalid versions. cc @samccone

@sebmck sebmck reopened this Oct 15, 2016
@sebmck sebmck changed the title warning $PKG@$VERSION: The engine "atom" appears to be invalid. How to handle invalid engines Oct 15, 2016
@samccone
Copy link
Member

This seems like an abuse of engines according to npm docs.

You can specify the version of node that your stuff works on:

{ "engines" : { "node" : ">=0.10.3 <0.12" } }
And, like with dependencies, if you don't specify the version (or if you specify "*" as the version), then any version of node will do.

If you specify an "engines" field, then npm will require that "node" be somewhere on that list. If "engines" is omitted, then npm will just assume that it works on node.

You can also use the "engines" field to specify which versions of npm are capable of properly installing your program.

@kevinastone
Copy link
Author

Seems to be pretty baked into Atom:
https://github.com/atom/package-generator/blob/master/package.json#L20-L22

@jdalton
Copy link
Contributor

jdalton commented Oct 15, 2016

Via the npm/doc/misc/npm-developers.md

engines: Specify the versions of node (or whatever else) that your program runs on. The node API changes a lot, and there may be bugs or new functionality that you depend on. Be explicit.

That wording was added in 2010 when the documentation was written.
Given that, the current level of validation seems unnecessary for this field.

fruitl00p added a commit to kingsquare/communibase-connector-js that referenced this issue Oct 31, 2016
I did however had to add the ignoring of the engines (`--ignore-engines`) since the communibase DEV depedency has "weird" engine specifications.. Yarn will probably lax the check soon (see yarnpkg/yarn#1102)
@mgol
Copy link

mgol commented Dec 21, 2016

Since npm not only doesn't enforce engines by default but also has removed the possibility to enforce it in package.json via "enginesStrict": true, package owners have been used to being able to use engines as a way to say "we've tested the project on those versions, we don't guarantee working on others". This doesn't mean the project won't work in other versions and it often does. One example of a package that uses engines like that is karma.

In the world where yarn is the only CLI client to the npm registry making engines enforced might work. However, the npm registry is primarily accessed via npm so if yarn is more strict than npm in a way that is contrary to how npm itself advises to use the engines field, that creates an incompatibility with the whole ecosystem. I don't think that's a good idea.

EDIT: Note that this also means that basically any project that enforces Node.js version somehow (even with a loose "node": ">=4") will not work on Node.js pre-releases as they don't meet this check. This is pretty invasive.

@hutson
Copy link

hutson commented Feb 14, 2017

For projects I'm responsible for, I use the engines property as a way to indicate which versions of Node I actively support, and on which versions of Node that particular version of the package should be capable of running on for eternity. As soon as a version of Node reaches end-of-life, I remove it from the engines property and release a new major version of the package. When a new version of Node enters LTS, I add it to the engines property (because I actively support LTS versions).

Users of those package may use use it with newer, unsupported, versions of Node if they wish. In the case of npm they'll just receive a warning that the package doesn't indicate support for that particular version of Node, so they need to accept a little risk with the decision. That's usually fine, and people can move forward with their work.

However, yarn's behavior makes unsupported Node versions a hard failure. Any attempt to use an unsupported Node version fails the yarn install process.

There's the hammer approach of using ignore-engines, but that provides no warning to the user that one or more dependencies are not officially supported on their version of Node.

@hutson
Copy link

hutson commented Feb 14, 2017

Perhaps we can just implement a pushWarning, similar to pushError (

const pushError = (msg) => {
) to call reporter.warn with the incompatibly, instead of erroring out.

@jkrems
Copy link
Contributor

jkrems commented Mar 30, 2017

As I mentioned in earlier discussions on this: There's also "I install this package because I want to bundle it into my client-side app. Why would I care that it wouldn't run in the version of node I happen to use to download the tar"?

I think even adding a help text for resolving the issue ("add the following to the .yarnrc file in this project to disable this check") would go a long way.

@hutson
Copy link

hutson commented Apr 1, 2017

Why would I care that it wouldn't run in the version of node I happen to use to download the tar"?

That's an excellent point, and as the JavaScript community consumes more npm packages for client-side applications, it's a point that more will want to raise.

add the following to the .yarnrc file in this project to disable this check

Would that suggestion apply to both dependencies and dev dependencies?

hutson added a commit to conventional-changelog/releaser-tools that referenced this issue Jun 3, 2017
Relax the `node` and `npm` version requirements specified in the
`engines` property of the project's `package.json` file.

Yarn checks the version range specified in a package's
`engines.node` property of the `package.json` file.

If you attempt to install a package using a Node version that does not
fall within that package's `engines.node` version range, Yarn will fail
during the install process. This is opposed to printing a warning like
the `npm` package manager does in this situation.

To install a package using a Node version outside of the package's range
you can pass the `--ignore-engines` flag to `yarn`.

Yarn issue related to the strict treatment of the `engines` data:
- yarnpkg/yarn#1102

We are relaxing the range since it does not seem Yarn will, any time
soon, provide a more convenient means of installing packages with
stricter `node` and `npm` version ranges.

While our `node` and `npm` version range was meant to correspond with
our Node LTS support policy, the disruption is too great to our
community. Instead, we will simply need to communicate our support
policy directly when engaging our community.

Closes #45
@gsklee
Copy link
Contributor

gsklee commented Jun 15, 2017

@bestander close; non-issue

@hutson
Copy link

hutson commented Jun 15, 2017

It should be noted that this issue was closed as the current Yarn behavior is working as designed.

Please see - yarnpkg/rfcs#69 (comment)

@gsklee
Copy link
Contributor

gsklee commented Jun 15, 2017

Yep, and another reason is that this issue was repurposed into a discussion which yielded no clear result. If anyone would like to continue the discussion of this topic, please continue inside the RFC @hbetts has linked. Thanks for the linking 😄

hutson added a commit to hyper-expanse/npm-deploy-git-tag that referenced this issue Jan 19, 2020
Relax the `node` and `npm` version requirements specified in the
`engines` property of the project's `package.json` file.

Yarn checks the version range specified in a package's
`engines.node` property of the `package.json` file.

If you attempt to install a package using a Node version that does not
fall within that package's `engines.node` version range, Yarn will fail
during the install process. This is opposed to printing a warning like
the `npm` package manager does in this situation.

To install a package using a Node version outside of the package's range
you can pass the `--ignore-engines` flag to `yarn`.

Yarn issue related to the strict treatment of the `engines` data:
- yarnpkg/yarn#1102

We are relaxing the range since it does not seem Yarn will, any time
soon, provide a more convenient means of installing packages with
stricter `node` and `npm` version ranges.

While our `node` and `npm` version range was meant to correspond with
our Node LTS support policy, the disruption is too great to our
community. Instead, we will simply need to communicate our support
policy directly when engaging our community.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests