1

I am trying to run a React Native test app on a web platform.
I have installed @react-native-community/async-storage dependency.
It generates the following error:

ERROR in ./node_modules/@react-native-community/async-storage/lib/AsyncStorage.js 40:5 Module parse failed: Unexpected token (40:5) You may need an appropriate loader to handle this file type. | } | type ReadOnlyArrayString = $ReadOnlyArray; | | type MultiGetCallbackFunction = ( @ ./node_modules/@react-native-community/async-storage/lib/index.js 5:0-42 7:15-27 @ ./src/app.js @ ./index.web.js @ multi (webpack)-dev-server/client?http://0.0.0.0:8080 (webpack)/hot/dev-server.js ./index.web.js

ERROR in ./node_modules/@react-native-community/async-storage/lib/hooks.js 7:5 Module parse failed: Unexpected token (7:5) You may need an appropriate loader to handle this file type. | import AsyncStorage from './AsyncStorage'; | type AsyncStorageHook = { | getItem: ( | callback?: ?(error: ?Error, result: string | null) => void, @ ./node_modules/@react-native-community/async-storage/lib/index.js 8:0-40 8:0-40 @ ./src/app.js @ ./index.web.js @ multi (webpack)-dev-server/client?http://0.0.0.0:8080 (webpack)/hot/dev-server.js ./index.web.js

Note: Code is running on Android, but it is not running on Web.

1
  • What do you mean "not running on web" for you React Native project? do you mean a webView? Commented Jan 9, 2020 at 16:56

1 Answer 1

2
resolve: {
    alias: {
        '@react-native-community/async-storage': 'react-native-web'
    }
}

create a resolve alias in your webpack.config.json.

This might help you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.