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 fails whenfsevents is an optional dependency and platform is linux #6050

Closed
tvjg opened this issue Jun 29, 2018 · 11 comments
Closed
Assignees
Labels

Comments

@tvjg
Copy link

tvjg commented Jun 29, 2018

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

Report a bug

What is the current behavior?

yarn import fails when a package has fsevents included as an optional transitive dependency. Using --ignore-optional does not appear to change the behavior.

┌[vagrant@host]─[~/repro-case]─[]
└[$]› yarn import
yarn import v1.7.0
info found npm package-lock.json, converting to yarn.lock
⠄ [email protected]
name: fsevents
parentNames: [ 'eslint-watch', 'chokidar' ]
error An unexpected error occurred: "Cannot read property 'version' of undefined".
info If you think this is a bug, please open a bug report with the information provided in "/home/vagrant/repro-case/yarn-error.log".


info Visit https://yarnpkg.com/en/docs/cli/import for documentation about this command.

Originally, this failed without any useful output, but I inserted some log statements into cli.js to identify the source of the failure. Interestingly, if I remove package-lock.json, the import works successfully against node_modules/, but produces a warning.

┌[vagrant@host]─[~/repro-case]─[]
└[$]› yarn import
yarn import v1.7.0
info creating yarn.lock from local node_modules folder
success Folder in sync.
warning Import of "eslint-watch@^3.1.4" for "test_web" failed, resolving normally.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
warning " > [email protected]" has unmet peer dependency "eslint@>=0.19.0 <5.0.0".
success Saved lockfile.
Done in 5.79s.

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

Run yarn import against the included package-lock.json. You should receive the error:

 An unexpected error occurred: "Cannot read property 'version' of undefined".

yarn-error.log

It would appear to have some relation to #5930, #6040, and #5366 .

What is the expected behavior?

yarn should generate a yarn.lock file.

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

┌[vagrant@host]─[~/repro-case]─[]
└[$]› node -v
v6.9.0

┌[vagrant@host]─[~/repro-case]─[]
└[$]› yarn -v
1.7.0

┌[vagrant@host]─[~/repro-case]─[]
└[$]› cat /etc/*release
CentOS release 6.6 (Final)
@ghost ghost assigned rally25rs Jun 29, 2018
@ghost ghost added the triaged label Jun 29, 2018
@rally25rs
Copy link
Contributor

@imsnif any ideas on this?

@imsnif
Copy link
Member

imsnif commented Jul 30, 2018

Interesting. AFAIK, (transitive) optional dependencies should still be included in package-lock.json - I might be wrong though (that's what happens for me locally, but the particularities here might be different).

It seems like in this package-lock.json the [email protected] package entry does not include the fsevents dependency, and so it is not included at all in the package-lock.json file. This is likely what's causing the issue.

@tvjg - would it be possible for you to include your package.json as well? That way we can check this out and know for certain (as well as come up with a holistic solution).

Meanwhile, I think if you remove node_modules and then npm install eslint-watch it should fix the package-lock.json file and then you'd be able to yarn import without issue. I'll be able to know for certain (and know where this problem likely came from) if I have access to the package.json file.

@imsnif
Copy link
Member

imsnif commented Jul 30, 2018

(also, thanks @tvjg for the debugging work, it was quite helpful)

@tvjg
Copy link
Author

tvjg commented Jul 31, 2018

Happy to contribute @iansu . I deleted the original repro case I had, but I was able to easily duplicate it again.

┌[vagrant@host]─[~/repro-case]─[]
└[$]› cat package.json 
{
  "name": "repro-case",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "eslint-watch": "^4.0.2"
  }
}

@imsnif
Copy link
Member

imsnif commented Jul 31, 2018

Hey @tvjg - so this package-lock.json file is definitely missing some deps. Good news is that it's totally fixable. This worked for me locally:

  1. Run npm install in the project's folder - this will update the package-lock.json with the missing deps.
  2. Run yarn import

Hope this helps, I'm closing this issue now - but let me know if it doesn't work out and I'll look into it.

@imsnif imsnif closed this as completed Jul 31, 2018
@tvjg
Copy link
Author

tvjg commented Aug 1, 2018

It appears to still be broken. Thinking that maybe I messed up recreating the file, I tried starting over from scratch with that package.json.

  1. npm install
  2. Confirm package-lock.json is generated
  3. yarn import
  4. Observe failure
  5. npm install
  6. yarn import
  7. Observe failure again

@imsnif
Copy link
Member

imsnif commented Aug 2, 2018

@tvjg - which version of npm are you using to install?

@tvjg
Copy link
Author

tvjg commented Aug 6, 2018

┌[vagrant@host]─[~/repro-case]─[]
└[$]› npm -v
5.1.0

@imsnif
Copy link
Member

imsnif commented Aug 6, 2018

I think that's the issue. Older versions of npm (iirc pre 6.1 but don't take my word for it!) did not place unsupported optional dependencies in package-lock.json. If you upgrade npm to the latest version (npm install -g npm) and then repeat the process (update the lockfile with npm install and then import) it should do the trick.

@imsnif
Copy link
Member

imsnif commented Nov 17, 2018

@kpower - even if you npm install with 6.4.1 before? Is fsevents in your package-lock.json?

@kpower
Copy link

kpower commented Nov 18, 2018

@imsnif sorry, the problem was on my shared hosting side (a bit later noticed it started display random errors during other tasks). No problems now (deleted original comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants