siddharthkp / cost-of-modules

Find out which of your dependencies are slowing you down 🐢
MIT License
2.84k stars 41 forks source link

SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) #66

Open dav1app opened 3 years ago

dav1app commented 3 years ago

For anyone that faces this issue, try updating to Node 16 and run the command again. You can just use it for this command, and then go back to your version!

There is an issue with this particular line:

// src/helper.js: 61:71
var getDependencyTree = function getDependencyTree() {
    var result = syncExec('npm ls --json ' + productionModifier);
    return JSON.parse(result.stdout).dependencies;
};

The problem is that syncExec uses a child_process.exec to execute the npm command, and depending on the size of the output, it might break due to the restrictions of the buffer size.