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

Json parse failure messages are misleading under some circumstances. #66

Open
hope-church-tritech opened this issue Jan 17, 2022 · 3 comments
Labels
good first issue Good for newcomers

Comments

@hope-church-tritech
Copy link

When an error occurs parsing the json from npm audit result while running better-npm-audit audit, the error message is:

Failed parsing .nsprc file: SyntaxError: Unexpected end of JSON input

Unable to process the JSON buffer string.

regardless of whether there is a .nsprc file.

The offending line is:

console.log('Failed parsing .nsprc file: ' + e);

@jeemok jeemok added the good first issue Good for newcomers label Jan 18, 2022
@jeemok
Copy link
Owner

jeemok commented Jan 18, 2022

Hi @hope-church-tritech, thanks for reporting this. I think it could be the JSON output from the npm audit result being invalid/incomplete.

May I know what would you see if you put a console.log('jsonBuffer', jsonBuffer); in your /node_modules/better-npm-audit/index.js around line 35, and run it again?

    // Once the stdout has completed, process the output
    if (audit.stderr) {
        audit.stderr.on('close', function () {
            console.log('jsonBuffer', jsonBuffer);
            // Analyze the npm audit response

@hope-church-tritech
Copy link
Author

The particular issue I was having was that the stderr & stdout of npm audit were both blank, causing the aforementioned output. This seems misleading since the .nsprc file was not where the invalid json was originating from, which was the impetus for writing up this issue.

I've already found and fixed what was causing my specific problem, which is that an ENOENT error occurs when trying to call npm audit on Ubuntu 20.04 when node is installed via snap instead of apt.

@msteel9999
Copy link

I was getting a similar issue because I misspelled .nsprc as .npmrc

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

No branches or pull requests

3 participants