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

fix(local): allow missing .version if not depended on #183

Closed
keyz opened this issue Dec 26, 2023 · 6 comments
Closed

fix(local): allow missing .version if not depended on #183

keyz opened this issue Dec 26, 2023 · 6 comments

Comments

@keyz
Copy link
Contributor

keyz commented Dec 26, 2023

Description

According to the npm spec, it's fine to omit the version field in package.json:

If you don't plan to publish your package, the name and version fields are optional

Omitting the version field is common for leaf packages that won't ever be published, such as "apps" in a monorepo. IMO this change (introduced by v12) feels like a regression.

Here's a simple repro. The following package.json declares a private package ("app"):

{
  "name": "my-express-app",
  "private": true,
  "scripts": {
    "repro": "syncpack list-mismatches"
  },
  "devDependencies": {
    "syncpack": "^12.0.1"
  }
}
$ npm run repro

> repro
> syncpack list-mismatches

= Default Version Group ========================================================
✘ my-express-app PACKAGE_JSON_HAS_NO_VERSION → ??? package.json > version [MissingLocalVersion]
  package.json does not have a .version property which is exact semver
     1 ✓ already valid
     1 ! can be fixed manually using syncpack prompt

Suggested Solution

Relax the policy such that leaf packages (that no one depends on) can omit the version field

Help Needed

@JamieMason
Copy link
Owner

Thanks I'll check it over, it should only happen if it is depended on.

https://jamiemason.github.io/syncpack/guide/status-codes/#missinglocalversion

@dbrxnds
Copy link

dbrxnds commented Dec 27, 2023

Running into this same issue now as well.

@JamieMason
Copy link
Owner

JamieMason commented Dec 27, 2023

I would stay on v11 for now if this is an issue – or add "version": "0.0.0" to the package.

@JamieMason JamieMason changed the title Since v12, every package.json must include a version field fix(local): allow missing .version if not depended on Dec 29, 2023
@JamieMason
Copy link
Owner

Released in 12.1.0.

👋 If anyone reading this finds syncpack useful, please tell people about it.

@bitofbreeze
Copy link

Is there a way to not require a version for all private packages?

@JamieMason
Copy link
Owner

A brief answer as I'm traveling right now but the latest version at https://github.com/JamieMason/syncpack/releases/tag/14.0.0-alpha.1 will warn on missing local versions but otherwise let you continue. Let me know if you need something more than this.

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

4 participants