Next.js: Wrong versioning for beta releases

Created on 19 Jun 2017  路  7Comments  路  Source: vercel/next.js

Having next ^3.0.0-beta or even next ^3.0.0-beta16 in my package.json or direct npm install 'next@^3.0.0-beta16' resolves to 3.0.0-beta9 (both npm and yarn behaves the same).

npm install 'next@beta' works fine, though.

This issue was also reported by @gragland in https://github.com/zeit/next.js/issues/2147#issuecomment-309241911

I am not sure if this is Next.js issue, but 2.x-beta releases worked as expected.

Most helpful comment

I've just published a new beta called [email protected].
Basically that's a best way I found to fix this issue.

All 7 comments

Yes, brought this up on Slack a while ago.

The current pre-release version format 3.0.0-beta16 is incorrect semver. It is meant to have a . separator: 3.0.0-beta.16. See here.

NPM sorts alphabetically the part after the . following the patch number, before the pre-release version number. Try running npm show next versions --json and you will see that 3.0.0-beta9 is considered a greater version than 3.0.0-beta16, because 9 > 1 when sorting that segment alphabetically.

Here is the tail chuck output from npm show next versions --json:

  "2.4.2",
  "2.4.3",
  "2.4.4",
  "3.0.0-beta1",
  "3.0.0-beta10",
  "3.0.0-beta11",
  "3.0.0-beta12",
  "3.0.0-beta13",
  "3.0.0-beta14",
  "3.0.0-beta15",
  "3.0.0-beta16",
  "3.0.0-beta2",
  "3.0.0-beta3",
  "3.0.0-beta4",
  "3.0.0-beta5",
  "3.0.0-beta6",
  "3.0.0-beta7",
  "3.0.0-beta8",
  "3.0.0-beta9"
]

Compared to npm show react versions --json:

  "15.5.2",
  "15.5.3",
  "15.5.4",
  "15.6.0-rc.1",
  "15.6.0",
  "15.6.1",
  "16.0.0-alpha",
  "16.0.0-alpha.0",
  "16.0.0-alpha.2",
  "16.0.0-alpha.3",
  "16.0.0-alpha.4",
  "16.0.0-alpha.5",
  "16.0.0-alpha.6",
  "16.0.0-alpha.7",
  "16.0.0-alpha.8",
  "16.0.0-alpha.9",
  "16.0.0-alpha.10",
  "16.0.0-alpha.11",
  "16.0.0-alpha.12",
  "16.0.0-alpha.13"
]

To work around the incorrect semver, save next: 3.0.0-beta16 without the ^.

Okay. This is a good point.
We can release next set of betas as of semvar.
Does that works well?

@arunoda I think 3.0.0-beta.17 would sort lower than 3.0.0-beta16?

The best way to fix it might be to move to RC, because r sorts greater than b: 3.0.0-rc.1

Checkout https://semver.npmjs.com, it's a really neat debug tool with semver examples.

Okay. I'll think about this.

I've just published a new beta called [email protected].
Basically that's a best way I found to fix this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knipferrc picture knipferrc  路  3Comments

formula349 picture formula349  路  3Comments

jesselee34 picture jesselee34  路  3Comments

lixiaoyan picture lixiaoyan  路  3Comments

havefive picture havefive  路  3Comments