Git Product home page Git Product logo

Comments (3)

tasshi-me avatar tasshi-me commented on August 16, 2024

Cause

The metro (a bundler for React Native) refers to the main field of package.json and injects browser platform dependencies.
Then, React Native environment throws an error because it doesn't have a location object.

Server log
Started Metro Bundler
iOS Bundling complete 7559ms
iOS Running app on iPhone (4)

ReferenceError: Can't find variable: location

This error is located at:
    in App (created by ExpoRoot)
    in ExpoRoot
    in RCTView (created by View)
    in View (created by AppContainer)
    in DevAppContainer (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent)
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/ReactFiberErrorDialog.js:52:4 in showErrorDialog
at node_modules/react-native/Libraries/ReactNative/renderApplication.js:76:4 in renderApplication
at node_modules/react-native/Libraries/ReactNative/AppRegistry.js:119:25 in runnables.appKey.run
at node_modules/react-native/Libraries/ReactNative/AppRegistry.js:213:4 in runApplication

ReferenceError: Can't find variable: location

This error is located at:
    in App (created by ExpoRoot)
    in ExpoRoot
    in RCTView (created by View)
    in View (created by AppContainer)
    in DevAppContainer (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent)
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:4 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0

Proposal

Add the react-native field to package.json and create React Native dependencies.
By default, metro refers react-native field before the browser and main fields.
https://facebook.github.io/metro/docs/configuration/#resolvermainfields

NOTE: metro does not yet support the exports field.
cf. facebook/metro#670 (comment)

from js-sdk.

tasshi-me avatar tasshi-me commented on August 16, 2024

When debugging with the local @kintone/rest-api-client, we have to copy the built package to my-project/node_modules.
It's because metro does not support yarn link(facebook/metro#68 and facebook/metro#1).

cp -rf path/to/js-sdk/packages/rest-api-client/ path/to/my-project/node_modules/@kintone/rest-api-client/

from js-sdk.

tasshi-me avatar tasshi-me commented on August 16, 2024

We don't support React Native environment but can throw a more helpful error message if location is not defined on browser environments.

from js-sdk.

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.