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

Incorrectly produces error when installed has prerelease tag and any version expected #28

Open
tomi opened this issue Apr 3, 2017 · 2 comments

Comments

@tomi
Copy link

tomi commented Apr 3, 2017

I have a package which has a prerelease tag in its version: 0.1.2-snapshot.125. In package.json any version (*) is accepted. This is incorrectly marked as an error.

package-name: installed: 0.1.2-snapshot.125, expected: *

@mgol
Copy link
Owner

mgol commented Apr 3, 2017

Thanks for the report.

This behaves exactly as in the semver package:

const semver = require('semver');
semver.satisfies("1.2.3", "*"); // true
semver.satisfies("1.2.3-beta.1", "*"); // false

The rationale is that by default version ranges should assume people want stable versions of packages; if you want to allow pre-release ones, you need to be explicit and even being explicit that you want to accept 1.0.0-beta doesn't mean 1.0.1-beta gets accepted:

const semver = require('semver');
semver.satisfies("1.0.0-beta.1", ">=1.0.0-beta"); // true
semver.satisfies("1.0.1-beta.1", ">=1.0.0-beta"); // false

That said, if you have * as a version range in package.json, npm install installs the pre-release version if none other is available and doesn't even print any warning (at least with npm 4.2.0). So relaxing that requirement sounds reasonable.

Would you like to submit a PR?

@tomi
Copy link
Author

tomi commented Apr 3, 2017

Unfortunately at this point I don't have the time to do a PR

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

2 participants