Skip to content

Unexpected end of JSON input #2700

Open
@kapilsriram

Description

@kapilsriram

I am facing similar issue as mentioned in #2540

whenever I run "eslint ." i am thrown "Unexpected end of JSON input"
image

Activity

ljharb

ljharb commented on Dec 27, 2022

@ljharb
Collaborator

What version of everything are you using? eslint 8.2 is out of date, try with eslint latest, and make sure you're on the latest of eslint-config-airbnb as well.

kapilsriram

kapilsriram commented on Dec 28, 2022

@kapilsriram
Author

i use 19.0.4 of eslint-config-airbnb and v8.30.0 of eslint. Still the same issue.
this is what i have in my eslint.json

extends": ["eslint:recommended","airbnb/whitespace"],

if i replace "airbnb/whitespace" with "airbnb" or even "airbnb/hooks" the issue is resolved. but wont work with whitespace for some reason

kapilsriram

kapilsriram commented on Dec 28, 2022

@kapilsriram
Author

image

kapilsriram

kapilsriram commented on Dec 28, 2022

@kapilsriram
Author

i have 2 different projects, with same issue, in one project, it opens "airbnb/whitespace-async.js" file in my notepad whenever i run "npm run lint" or "eslint ."

ljharb

ljharb commented on Dec 28, 2022

@ljharb
Collaborator

The way the eslint-config-airbnb/whitespace file works is it executes https://unpkg.com/browse/eslint-config-airbnb@19.0.4/whitespace-async.js - which is an executable node program - and it outputs JSON.

If that file is being opened in your editor then perhaps the executable bit isn't set properly on that file, or perhaps something about your system isn't supporting execSync of an executable JS file. It's possible this happens on any Windows machine, but I'd be pretty surprised if you were the first Windows user to use the whitespace config.

If it's a problem on all Windows machines, then we might need to change the approach we use to execute the whitespace-async file.

kapilsriram

kapilsriram commented on Dec 29, 2022

@kapilsriram
Author

the problem didnt exist in older versions, only in the latest versions we r facing the issue. Previously we used 18.2.0 with typescript 3.9.10

ljharb

ljharb commented on Dec 29, 2022

@ljharb
Collaborator

yes, this technique was introduced to be compatible with eslint 8.

kapilsriram

kapilsriram commented on Dec 30, 2022

@kapilsriram
Author

is it possible to fix this thing? or can give me a hint of how to get around this, I can give a try and probably will contribute the update

ljharb

ljharb commented on Dec 30, 2022

@ljharb
Collaborator

I believe that what's required is either finding a package that can sync exec a node file on linux/mac and windows - or, detecting windows, and using an alternative sync approach on windows (all in the whitespace file, to exec the whitespace-async file).

kapilsriram

kapilsriram commented on Jan 2, 2023

@kapilsriram
Author

image
by adding "node " to the command, the issue seized, is this the expected functionality? we are only trying to run the js file in node isnt?

ljharb

ljharb commented on Jan 2, 2023

@ljharb
Collaborator

i don't know what you mean by "seized" here - but certainly if running it directly with node fixes the problem, that might work.

kapilsriram

kapilsriram commented on Jan 3, 2023

@kapilsriram
Author

i mean stopped. cool. I was just checking if "node " does the same thing as it was doing previoulsy

ljharb

ljharb commented on Jan 3, 2023

@ljharb
Collaborator

Yes, it should be unnecessary, but it also doesn't hurt. Want to make a PR?

kapilsriram

kapilsriram commented on Jan 6, 2023

@kapilsriram
Author

yep sure.

meta-panic

meta-panic commented on Feb 12, 2023

@meta-panic

I faced the very same issue recently. So, the problem was the line #!/usr/bin/env node here

My fix:

  1. Create/update the symlink at /usr/bin ln -s <path_to_your_nodejs> /usr/bin/node
  2. Check permission(I just set 777 and that's all)

I hope it'will work for someone else

meta-panic

meta-panic commented on Feb 12, 2023

@meta-panic

@kapilsriram hi! Maybe my workaround could help you

Oms-343

Oms-343 commented on Mar 4, 2023

@Oms-343

@meta-panic could you please elaborate..? I am facing the same issue .

Oms-343

Oms-343 commented on Mar 6, 2023

@Oms-343

@kapilsriram your solution helped. Thankyou👍

postmeback

postmeback commented on May 29, 2023

@postmeback

Looks like the fix worked for many people.

IMHO, The PR and the issue both can get resolved.

zaycker

zaycker commented on Feb 24, 2025

@zaycker

Yes, it should be unnecessary

sorry for my appearing after years...
it is called "shebang" (Ricky Martin wrote a song about it), and it was also mentioned by @meta-panic
shebangs don't work under Windows at all, those headers with interpreter definitions starting with #!
that's why node should be defined explicitly in execSync to be cross-platform otherwise it cannot be executed under Windows

but I'd be pretty surprised if you were the first Windows user to use the whitespace config.

I think people just removed the "airbnb/whitespace" line after they met the issue under Windows (the case of my project - all windows devs have commented the line in the eslint config)

thelittleerik

thelittleerik commented on Feb 27, 2025

@thelittleerik

fck microsoft how is this still an issue, @kapilsriram your solution fixed it. Thanks

image by adding "node " to the command, the issue seized, is this the expected functionality? we are only trying to run the js file in node isnt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ljharb@zaycker@kapilsriram@postmeback@meta-panic

      Issue actions

        Unexpected end of JSON input · Issue #2700 · airbnb/javascript