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

eslint --init fails with "TypeError: Cannot read property 'trim' of null" when npm is not installed #9102

Closed
athei opened this issue Aug 13, 2017 · 4 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly cli Relates to ESLint's command-line interface

Comments

@athei
Copy link

athei commented Aug 13, 2017

Tell us about your environment

  • ESLint Version: 4.4.1
  • Node Version: 8.3.0
  • npm Version: Using yarn 0.27.5

What parser (default, Babel-ESLint, etc.) are you using?
Right now I am just initializing the config.

What did you do? Please include the actual source code causing the issue.
I am trying to use eslint for a project. I just installed it locally using package.json and yarn and run ./node_modules/.bin/eslint --init.

What did you expect to happen?
I expect a .eslintrc to be written.

What actually happened? Please include the actual, raw output from ESLint.

? How would you like to configure ESLint? Use a popular style guide
? Which style guide do you want to follow? Airbnb
? Do you use React? Yes
? What format do you want your config file to be in? JSON
Checking peerDependencies of eslint-config-airbnb@latest
Cannot read property 'trim' of null
TypeError: Cannot read property 'trim' of null
    at Object.fetchPeerDependencies (/Users/alexander/Developer/seduceme/web-react/node_modules/eslint/lib/util/npm-util.js:69:13)
    at getPeerDependencies (/Users/alexander/Developer/seduceme/web-react/node_modules/eslint/lib/config/config-initializer.js:75:26)
    at hasESLintVersionConflict (/Users/alexander/Developer/seduceme/web-react/node_modules/eslint/lib/config/config-initializer.js:359:40)
    at Object.when (/Users/alexander/Developer/seduceme/web-react/node_modules/eslint/lib/config/config-initializer.js:452:83)
    at /Users/alexander/Developer/seduceme/web-react/node_modules/run-async/index.js:25:25
    at Promise (<anonymous>)
    at /Users/alexander/Developer/seduceme/web-react/node_modules/run-async/index.js:24:19
    at /Users/alexander/Developer/seduceme/web-react/node_modules/inquirer/lib/ui/prompt.js:106:30
    at tryCatcher (/Users/alexander/Developer/seduceme/web-react/node_modules/rx-lite/rx.lite.js:67:31)
    at Defer.subscribeCore (/Users/alexander/Developer/seduceme/web-react/node_modules/rx-lite/rx.lite.js:2159:37)
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 13, 2017
@not-an-aardvark not-an-aardvark added bug ESLint is working incorrectly cli Relates to ESLint's command-line interface evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Aug 23, 2017
@not-an-aardvark
Copy link
Member

Thanks for the report. What operating system and terminal are you using?

@GAumala
Copy link
Contributor

GAumala commented Aug 28, 2017

I'm also having this issue. After reading the line pointed by the stack trace, I believe that the problem is that fetchPeerDependencies() assumes that there is an npm installation somewhere in path in order to run npm show in a child process.

The minimum solution right now would be to handle the error of the child process and show a nice error message like "Error: do you have npm installed?".

A better solution would be to try to use yarn if there's no npm installed, but I don't know if yarn supports the show command. Now that I think about it, I can't find anything about show in the npm documentation site. I wonder if yarn info is the equivalent to this command...

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Aug 28, 2017
@not-an-aardvark
Copy link
Member

Thanks, in that case I agree that we should handle the error more gracefully.

For more discussion about using yarn, see #8787 and #9023.

@not-an-aardvark not-an-aardvark changed the title eslint --init fails with: TypeError: Cannot read property 'trim' of null eslint --init fails with: TypeError: Cannot read property 'trim' of null when npm is not installed Aug 28, 2017
@not-an-aardvark not-an-aardvark changed the title eslint --init fails with: TypeError: Cannot read property 'trim' of null when npm is not installed eslint --init fails with "TypeError: Cannot read property 'trim' of null" when npm is not installed Aug 28, 2017
@not-an-aardvark
Copy link
Member

Fixed in #9169

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 27, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly cli Relates to ESLint's command-line interface
Projects
None yet
Development

No branches or pull requests

4 participants