Git Product home page Git Product logo

Comments (16)

vjeux avatar vjeux commented on March 29, 2024

cc @amasad

from react-native.

jimjeffers avatar jimjeffers commented on March 29, 2024

I'm running into the same issue here. Here are my local node and npm versions just for reference:

→ npm -v
2.1.7

→ node -v
v0.10.33

from react-native.

amasad avatar amasad commented on March 29, 2024

That failure is at a line where it's trying to JSON.parse a package.json file. I'm looking into this now but do you have any custom node module that may have a malformed package.json?

from react-native.

amasad avatar amasad commented on March 29, 2024

Hey @jimjeffers @ColinEberhardt can you add a console.log(content) before this line https://github.com/facebook/react-native/blob/master/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js#L270
That way we know what is failing to parse.

from react-native.

ColinEberhardt avatar ColinEberhardt commented on March 29, 2024

Thanks @amasad - this is the strange thing, when I add a console.log ...

      .then(function(content) {
        console.log(content);
        var packageJson = JSON.parse(content);

I observe the following:

--- snip lots of package.json output above ---
{
    "main" : "./lib"
}

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at /Users/colineberhardt/Projects/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:271:32
    at _fulfilled (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:749:13)
    at /Users/colineberhardt/Projects/react-native/node_modules/q/q.js:557:44
    at flush (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:442:13)
[20:29:18] <START> find dependencies

i.e. it outputs lots of package.json output, all of which looks fine. Then it hits the error but I don't see content in the console log.

I've added logging to try and determine which file is causing issues:

    if (packagePath != null) {
      console.log('opening package: ' + packagePath);
      return readFile(packagePath, 'utf8')
        .then(function(content) {
          console.log('opened package: ' + packagePath);
          var packageJson = JSON.parse(content);

On npm start I see a whole lot of logging, ending as follows:

opening package: /Users/colineberhardt/Projects/react-native/node_modules/react-tools/node_modules/commoner/node_modules/recast/node_modules/source-map/node_modules/amdefine/package.json
opened package: /Users/colineberhardt/Projects/react-native/node_modules/react-tools/node_modules/commoner/node_modules/recast/node_modules/source-map/node_modules/amdefine/package.json
opening package: /Users/colineberhardt/Projects/react-native/node_modules/module-deps/node_modules/browser-resolve/node_modules/resolve/test/resolver/biz/node_modules/garply/package.json
opened package: /Users/colineberhardt/Projects/react-native/node_modules/module-deps/node_modules/browser-resolve/node_modules/resolve/test/resolver/biz/node_modules/garply/package.json

Then as soon as I hit the URL in the browser, the following error is logged:

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at /Users/colineberhardt/Projects/react-native/packager/react-packager/src/DependencyResolver/haste/DependencyGraph/index.js:272:32
    at _fulfilled (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:749:13)
    at /Users/colineberhardt/Projects/react-native/node_modules/q/q.js:557:44
    at flush (/Users/colineberhardt/Projects/react-native/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:442:13)
[20:34:18] <START> find dependencies

I'm a bit baffled as i would have expected some logging before the error to indicate which package.json it was opening.

Confused!

from react-native.

vjeux avatar vjeux commented on March 29, 2024

@amasad would be nice to add a proper error message if a package.json file is malformed

from react-native.

amasad avatar amasad commented on March 29, 2024

It seems like it's choking on some test package.json files. I think we should ignore malformed package.json and just warn when building the dependency graph. Once the user require that module will figure out that something is wrong.

from react-native.

amasad avatar amasad commented on March 29, 2024

@ColinEberhardt will land a fix soon but try this for now:

-        var packageJson = JSON.parse(content);
-        if (packageJson.name == null) {
+        var packageJson;
+        try {
+          packageJson = JSON.parse(content);
+        } catch (e) {
+          debug('WARNING: malformed package.json: ', packagePath);
+          return q();
+        }

from react-native.

ColinEberhardt avatar ColinEberhardt commented on March 29, 2024

Thanks @amasad - here's the culprit:

WARNING: malformed package.json:  /Users/colineberhardt/Projects/react-native/node_modules/npm/test/fixtures/config/package.json

from react-native.

amasad avatar amasad commented on March 29, 2024

Interesting, why do you have npm in mode_modules? Do we require it as a
dependency?

Regardless, will land the fix to ignore these malformed packages.

On Saturday, February 7, 2015, Colin Eberhardt [email protected]
wrote:

Thanks @amasad https://github.com/amasad - here's the culprit:

WARNING: malformed package.json: /Users/colineberhardt/Projects/react-native/node_modules/npm/test/fixtures/config/package.json


Reply to this email directly or view it on GitHub
#47 (comment)
.

from react-native.

ColinEberhardt avatar ColinEberhardt commented on March 29, 2024

Ahhhh!!! Found the issue - I mistakenly cut and paste the instructions from the README:

npm install npm start

Note, the lack of line-break, which causes an npm install npm. Must have just been running on auto-pilot!

from react-native.

amasad avatar amasad commented on March 29, 2024

Haha no worries at all. Thanks for exposing this bug

On Saturday, February 7, 2015, Colin Eberhardt [email protected]
wrote:

Ahhhh!!! Found the issue - I mistakenly cut and paste the instructions
from the README:

npm install npm start

Note, the lack of line-break, which causes an npm install npm. Must have
just been running on auto-pilot!


Reply to this email directly or view it on GitHub
#47 (comment)
.

from react-native.

vjeux avatar vjeux commented on March 29, 2024

We fixed both the README and the error message. Thanks for this!

from react-native.

Haroenv avatar Haroenv commented on March 29, 2024

I have this error message without a path, did something get reverted?

Problem checking node_modules dependencies: Unexpected end of JSON input

from react-native.

joshkarges avatar joshkarges commented on March 29, 2024

I have @Haroenv's same issue.

from react-native.

yemarnevets avatar yemarnevets commented on March 29, 2024

I did a complete fresh install from the guide: https://facebook.github.io/react-native/docs/getting-started.html and I'm still running into this issue. The error message is quite cryptic. I'd hope for more detail in development mode. "07:53:10: Problem checking node_modules dependencies: Unexpected end of JSON input"

from react-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.