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

Yarn import error - cannot read property 'version' of undefined #5930

Closed
cdimitroulas opened this issue Jun 4, 2018 · 6 comments
Closed
Assignees

Comments

@cdimitroulas
Copy link

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)

@ghost ghost assigned torifat Jun 4, 2018
@ghost ghost added the triaged label Jun 4, 2018
@imsnif imsnif assigned imsnif and unassigned torifat Jun 4, 2018
@imsnif
Copy link
Member

imsnif commented Jun 4, 2018

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!

@cdimitroulas
Copy link
Author

cdimitroulas commented Jun 5, 2018

@imsnif
Copy link
Member

imsnif commented Jun 7, 2018

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: #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.

@cdimitroulas
Copy link
Author

cdimitroulas commented Jun 7, 2018

Honestly, I am very impressed with the turnaround on this issue 💯

Thanks so much, your solution worked and you got back to me so quickly 🙏

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 ?

@imsnif
Copy link
Member

imsnif commented Jun 7, 2018

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.

@imsnif
Copy link
Member

imsnif commented Jun 11, 2018

Fixed in 1.8.0

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