flow icon indicating copy to clipboard operation
flow copied to clipboard

Flow fails to parse a valid package.json file

Open davidye opened this issue 8 years ago • 15 comments

My project has a dependency on https://github.com/creationix/http-parser-js/blob/master/package.json. Flow throws this error:

Error: node_modules/http-parser-js/package.json:1 1: { ^ Unexpected end of input

It looks like it's because these two lines here: https://github.com/creationix/http-parser-js/blob/master/package.json#L21-L22 contain ä and ü. But this should be valid json?

davidye avatar Sep 13 '17 02:09 davidye

I've re-encoded http-parser-js/package.json in UTF8, and published http-parser-js to NPM, please let me know if it fixes the issue for you.

Jimbly avatar Sep 13 '17 14:09 Jimbly

I think that package.json is supposed to be UTF8 encoded, however one could argue that NPM parses it without complaints, you may want your system to be able to parse it as well, so even if this "fixes" the issue in this case there might still be a bug here in flow.

Jimbly avatar Sep 13 '17 14:09 Jimbly

@Jimbly Thanks! I was also running into this issue, and it's fixed for me now that I bumped to 0.4.6.

dylnclrk avatar Sep 13 '17 15:09 dylnclrk

Hi,

I've been bitten by this issue, having to deploy an update to a legacy Node.js app. I have discovered an issue of interest.

Installing the http-parser-js npm module on Linux (Ubuntu 14.04 LTS) with Node 0.8.27 (I know, legacy!) does not install the http-parser.js file. It only copies the package.json and README.md files.

I managed to determine that this issue goes back to 0.4.3, and that 0.4.2 of the module does install the http-parser.js file.

I will isolate which commit introduces the issue of npm install not installing the http-parser.js file when installing the http-parser-js module.

paulbjensen avatar Sep 21 '17 10:09 paulbjensen

I found the commit that resulted in this occurring:

https://github.com/creationix/http-parser-js/commit/0bd74fde0627e0e549dfe341ddfe06f521515ee0

paulbjensen avatar Sep 21 '17 10:09 paulbjensen

So the current version of the package.json file still has files as an empty array, which could explain why this is failing to install the file on older versions of npm on Linux.

paulbjensen avatar Sep 21 '17 10:09 paulbjensen

@paulbjensen Your issue sounds unrelated to this bug (other than that it's happening with the same module), perhaps open a new bug on the appropriate project and it can be discussed there.

Jimbly avatar Sep 21 '17 13:09 Jimbly

Ah, sorry, didn't see you already did over at https://github.com/creationix/http-parser-js/issues/41 ; will continue discussion there.

Jimbly avatar Sep 21 '17 13:09 Jimbly

I can't repro this, is still an issue?

goodmind avatar Jun 04 '19 06:06 goodmind

I don't think it is anymore, as http-parser-js doesn't appear to be an explicit dependency of flow (at least not from a scan of the yarn.lock file).

paulbjensen avatar Jun 04 '19 12:06 paulbjensen

http-parser-js was never a dependency of flow. The issue, as I understood it, was that flow parses a project's dependencies, and was failing to parse a package.json that NPM had no problem with (though was possibly technically incorrect). In theory a project explicitly depending on [email protected] would probably get the offending package.json. I have no idea if this is still and issue, and really have no idea what flow is, other than what I've read in this one bug, so could be totally misled =).

Jimbly avatar Jun 04 '19 14:06 Jimbly

Ah, I was trying package.json from master

goodmind avatar Jun 05 '19 00:06 goodmind

Yeah, there is still parse error with this image Even VSCode can't display it properly image

goodmind avatar Jun 05 '19 03:06 goodmind

Yeah, I think it was saved with ASCII encoding (Notepad will view it fine ; ), instead of UTF8, so has bytes that are not valid when interpreted as UTF8.

Jimbly avatar Jun 05 '19 06:06 Jimbly

Hello, My workflow is giving me the following error when running. I have check package.json, there isn't anything wrong. Character 'l' appears when executing the package.json command. There is a parsing issue. I don't know how to solve it. out: npm ERR! JSON.parse Unexpected token l in JSON at position 0 while parsing near 'l{

Screenshot from 2022-09-26 01-10-52

abdulbari149 avatar Sep 25 '22 20:09 abdulbari149