-
Notifications
You must be signed in to change notification settings - Fork 3k
have npm report the error with a package.json #3869
Comments
I don't believe any JSON parsers expose this information, and we just use |
I know, I'm not saying to use jshint instead of JSON parsing, but that it would be very helpful if, after a JSON.parse throws its parse error, that error is handled by running the package.json file that we now know has errors through a JS linter, which unlike JSON.parse will find the error tied to a location in the file and an error case number, which can then be reported as additional information. e.g.:
or some such. Once you know that package.json is guaranteed to have an error it can be run through a linter to find the exact location and nature of the error, so that the user can find out what's wrong much faster than they currently can. |
Yeah, I got that. But do you know of any JSON parsers that include line numbers in their error messages? JSHint isn't a JSON parser, so that won't work. (E.g. if your syntax error is forgetting quotes, JSHint will be fine with that.) |
Hmm, what about https://github.com/zaach/jsonlint ? |
Could work. Would be helpful to run some tests on different invalid inputs and see what it gives you. |
+1 |
Any progress on this? Seems like something so simple but so important when all that is usually missing is a comma or something visually insignificant. |
since npm relies on a well formatted package.json file, it would be nice if it could report the actual error it sees when trying to parse a bad package.json rather than merely reporting that there is some error without saying which line/column or the type of error encountered. If there is a JSON parse error perhaps the package.json file could be thrown at jshint to get the precise error?
The text was updated successfully, but these errors were encountered: