yarn upgrade-interactive fails with Invalid version: undefined error if a dependency has only prerelease versions

Created on 8 Jun 2018  路  7Comments  路  Source: yarnpkg/yarn

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

What is the current behavior?
When running yarn upgrade-interactive and a dependency does not have a "latest" version then it fails with an error "Invalid version: undefined"

If the current behavior is a bug, please provide the steps to reproduce.

  • add a dependency that does not have a "latest" tag (only prerelease versions published with tag "beta")
  • run yarn upgrade-interactive

What is the expected behavior?
The command should run successfully and show the upgradeable versions of all packages.

If the package in question has a later prerelease version, that version should be suggested to be upgraded to.

Please mention your node.js, yarn and operating system version.

Arguments:
C:\Program Files (x86)\node\node.exe C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js upgrade-interactive

Yarn version:
1.7.0

Node version:
8.11.1

Platform:
win32 x64

Trace:
TypeError: Invalid Version: undefined
at new SemVer (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\libcli.js:2465:11)
at SemVer.module.exports.SemVer.compare (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\libcli.js:2528:13)
at compare (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\libcli.js:2752:31)
at Function.lt (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\libcli.js:2786:10)
at isDepOld (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\libcli.js:36817:134)
at Array.filter ()
at Function. (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\libcli.js:36822:19)
at Generator.next ()
at step (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\libcli.js:98:30)
at C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\libcli.js:109:13

cat-bug good first issue help wanted

Most helpful comment

Can i try this one? Its my first time contributing to open source.

All 7 comments

Interesting. I'd never seen a package where the npm registry didn't return a latest. We should do something to handle those.
I suspect (but have not debugged to check) that this caused by this line: https://github.com/yarnpkg/yarn/blob/master/src/package-request.js#L443 which passes the value of latest to semver.lt() if someone wants to work up a PR 馃樃

this happened when we were using our own internal registry and had only published versions of some packages with a beta tag

Can i try this one? Its my first time contributing to open source.

@kpbl Sure! We appreciate the help! If you submit a PR, you should be able to mark me as a requested reviewer. Be sure to add a unit test too if you can. Thanks! 馃樃

I do not really know how to test this because i have no private registry.
I want to add a test to https://github.com/yarnpkg/yarn/blob/master/__tests__/commands/upgrade-interactive.js is that the correct way?

@rally25rs any tips?

I believe to test this it should be possible to add a new package to the official npm registry which only has a "beta" tag defined and is a prerelease version. Not sure how this would work in a unit test though.

Was this page helpful?
0 / 5 - 0 ratings