Do you want to request a feature or report a bug?
I am reporting a bug
What is the current behavior?
Running yarn import fails with the error:
An unexpected error occurred: "Cannot read property 'version' of undefined".
The full error log:
Arguments:
/home/cdimitroulas/.nvm/versions/node/v8.11.2/bin/node /usr/share/yarn/bin/yarn.js import
PATH:
# Omitted
Yarn version:
1.7.0
Node version:
8.11.2
Platform:
linux x64
Trace:
TypeError: Cannot read property 'version' of undefined
at LogicalDependencyTree.getFixedVersionPattern (/usr/share/yarn/lib/cli.js:96794:24)
at ImportPackageResolver.<anonymous> (/usr/share/yarn/lib/cli.js:86608:75)
at Generator.next (<anonymous>)
at step (/usr/share/yarn/lib/cli.js:98:30)
at /usr/share/yarn/lib/cli.js:116:14
at new Promise (<anonymous>)
at new F (/usr/share/yarn/lib/cli.js:23451:28)
at ImportPackageResolver.<anonymous> (/usr/share/yarn/lib/cli.js:95:12)
at ImportPackageResolver.findOne (/usr/share/yarn/lib/cli.js:86614:20)
at /usr/share/yarn/lib/cli.js:86625:23
What is the expected behavior?
yarn import should create a yarn.lock file from the package-lock.json file.
Please mention your node.js, yarn and operating system version.
Node.js version - 8.11.2 (Using nvm)
Yarn version - 1.7.0
OS - Ubuntu 16.04 (linux x64)
Hey @cdimitroulas - would it be possible for you to share your package.json and package-lock.json? I'll need them in order to look into this. Thanks!
Hey @imsnif, of course - here you go!
https://drive.google.com/drive/folders/1C6qKiYCCs4FC_d8wtKpzrmGwt99dxvcs?usp=sharing
Hi @cdimitroulas - first, thanks for reporting this and being willing to share your package.json and package-lock.json files. It helped discover an issue both in yarn and in npm!
In short, what happens here is that because of a (really really edge case) issue with npm - your package-lock.json was constructed incorrectly. I opened an issue for npm in which you can read the full details if you'd like: https://npm.community/t/npm-does-not-install-github-deep-dependencies-with-a-since-mutated-package-json/207
A certain deep Github dependency was not added to package-lock.json upon install, and so when yarn was trying to import it - it failed with an unhelpful error and no recourse. This is the issue in yarn. I created a patch that fixes it by giving a helpful warning message in such cases and resolving the dependency normally from the registry (or from Github in this case). You can follow it here if you'd like: https://github.com/yarnpkg/yarn/pull/5947
For now, until the PR is merged and a new version released, I can offer a workaround that is not ideal but should solve your issue in a pinch:
npm uninstall feathers-service-verify-reset
yarn import
yarn add feathers-service-verify-reset@^1.0.0
The "offending" dependency is get-parameter-names which is a deep child of feathers-service-verify-reset. By uninstalling it, importing and then reinstalling it you should be good. But PLEASE NOTE - this will remove the version locks from feathers-service-verify-reset and all of its sub dependencies. If you go this route, I recommend thoroughly testing everything to make sure nothing was broken.
Honestly, I am very impressed with the turnaround on this issue :100:
Thanks so much, your solution worked and you got back to me so quickly :pray:
One last thing - I can't see the get-parameter-names dependency anywhere in the package-lock.json after following your instructions. I tried adding the library with yarn instead of npm and I can see the dependency in yarn.lock.
Perhaps your last command was meant to say yarn add feathers-service-verify-reset@^1.0.0 ?
Perhaps your last command was meant to say yarn add feathers-service-verify-reset@^1.0.0 ?
Hot damn! You're correct. Too much typing today :) Edited.
Fixed in 1.8.0
Most helpful comment
Hi @cdimitroulas - first, thanks for reporting this and being willing to share your
package.jsonandpackage-lock.jsonfiles. It helped discover an issue both inyarnand innpm!In short, what happens here is that because of a (really really edge case) issue with
npm- yourpackage-lock.jsonwas constructed incorrectly. I opened an issue for npm in which you can read the full details if you'd like: https://npm.community/t/npm-does-not-install-github-deep-dependencies-with-a-since-mutated-package-json/207A certain deep Github dependency was not added to
package-lock.jsonupon install, and so whenyarnwas trying to import it - it failed with an unhelpful error and no recourse. This is the issue inyarn. I created a patch that fixes it by giving a helpfulwarningmessage in such cases and resolving the dependency normally from the registry (or from Github in this case). You can follow it here if you'd like: https://github.com/yarnpkg/yarn/pull/5947For now, until the PR is merged and a new version released, I can offer a workaround that is not ideal but should solve your issue in a pinch:
The "offending" dependency is
get-parameter-nameswhich is a deep child offeathers-service-verify-reset. By uninstalling it, importing and then reinstalling it you should be good. But PLEASE NOTE - this will remove the version locks fromfeathers-service-verify-resetand all of its sub dependencies. If you go this route, I recommend thoroughly testing everything to make sure nothing was broken.