Skip to content

Unhandled JS Exception: Unexpected token '{'. import call expects exactly one argument. no stack #24094

Closed

Description

@Steffi3rd

Everything's work fine until I build my project on Xcode to see my app on real device...

Everything is build fine with no errors, yarn start and Xcode Play button (for build)

Capture d’écran 2019-03-21 à 23 06 17

$ react-native info
info 
  React Native Environment Info:
    System:
      OS: macOS 10.14.1
      CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
      Memory: 170.70 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.10.0 - /usr/local/bin/node
      Yarn: 1.13.0 - /usr/local/bin/yarn
      npm: 6.7.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    IDEs:
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.0 => 0.59.0

Activity

  1. karanjthakkar commented on Mar 21, 2019

    @karanjthakkar
    Contributor

    Can you provide a minimal reproducible example for this? That would help us narrow down the issue better.

  2. Gerlison commented on Mar 22, 2019

    @Gerlison

    Seems like a error in your code. Can you provide a screenshot of console with Debug JS Remotely?

  3. turnrye commented on Mar 22, 2019

    @turnrye
    Contributor

    Hey @Steffi3rd, I suspect that there's actually an issue in your project's code. I think if you look at Metro, you'll see a build-time error.

    A few tips:

    1. Try resetting all of the caches with:
     watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean --force && npm install && npm start -- --reset-cache
    1. Go ahead and upgrade to 0.59.1

    Without a repository of your source, it's hard to give specific advice. This seems like an environment issue, but please do follow up with more detail if my pointers above don't help.

  4. Steffi3rd commented on Mar 22, 2019

    @Steffi3rd
    Author

    Thanks for your anwser, I did this :

    watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean --force && npm install && npm start -- --reset-cache
    

    Now the error has changed but similar.
    I don't any details on "Extra Info"

    • It works very well on Simulator.
    • Metro bundler is build fine
    • Xcode project build success

    IMG_9447

    IMG_810D99BDE348-1

  5. SourceCipher commented on May 12, 2019

    @SourceCipher

    Having the same issue.. Cant see whats causing this nonsense.. Metro running fine, everything compiles.. Upon app launch this error comes up with no indication.. Nothing in the console either..

  6. MaxBabenko commented on May 23, 2019

    @MaxBabenko

    Got the same error. Renaming root index.js to index.ios.js did the trick for me. But I'm not sure what is the real issue here

  7. gianpaj commented on May 24, 2019

    @gianpaj

    Upgrading to these versions seems to have fixed this issue for me on react-native v0.59.8

    package.json

       "devDependencies": {
    -    "@babel/core": "^7.4.4",
    -    "@babel/runtime": "^7.4.4",
    +    "@babel/core": "^7.4.5",
    +    "@babel/runtime": "^7.4.5",
    @@ -101,7 +101,7 @@
    -    "metro-react-native-babel-preset": "^0.54.0",
    +    "metro-react-native-babel-preset": "^0.54.1",
  8. satya164 commented on May 30, 2019

    @satya164
    Contributor

    I'm closing this issue since no repro was provided.

  9. jeffreyhaen commented on Jun 13, 2019

    @jeffreyhaen

    I'm having the same issue after upgrading to RN 0.59.9. The error message gives basically no clue what's wrong...

  10. unmec commented on Sep 11, 2019

    @unmec

    I had a similar issue with error Unhandled JS Exception: Unexpected identifier 'App'. import call expects exactly one argument. no stack

    So the problem is apparently import App from './App';

    I had several code blocks and reminders commented out above it, removing all these comments then the build is successful. So I suggest you to check your import methods.

    Also, be careful when comment out code in RN in general, especially within render function. Hope it's helpful.

  11. unmec commented on Sep 11, 2019

    @unmec

    UPDATE

    OK here is the digest of a few good hours spent:

    In your index.js, there is something like this:

    import { name as appName } from './app.json';
    AppRegistry.registerComponent(appName, () => App);
    

    Which import the name from app.json

    {
      "name": "yourAppName",
      "displayName": "yourAppName"
    }
    

    To get rid of this error, just change index.js to:

    AppRegistry.registerComponent('yourAppName', () => App);
    

    and stop importing that json file.

    You can keep all your present settings in devDependencies

  12. ghasemikasra39 commented on Oct 5, 2019

    @ghasemikasra39

    same issue

  13. wuweijian1997 commented on Oct 24, 2019

    @wuweijian1997

    Windows 10 - Android
    image
    info React Native Environment Info: System: OS: Windows 10 CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz Memory: 1.19 GB / 7.91 GB Binaries: Node: 10.16.3 - C:\kafka\setting\node\node.EXE Yarn: 1.19.1 - C:\kafka\setting\yarn\bin\yarn.CMD npm: 6.9.0 - C:\kafka\setting\node\npm.CMD
    same issue

  14. ajGingrich commented on Oct 27, 2019

    @ajGingrich

    I fixed this problem by deleting the entire babel.config.js for the time being and letting react-native handle babel

  15. wonga151 commented on Feb 9, 2020

    @wonga151

    If this helps anyone I had the same issue and this helped me solve it. #21530 (comment)

  16. locked as resolved and limited conversation to collaborators on May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions