Skip to content

Failed to Compile while trying to run Hello Mobile Navigation with react-native-web #622

@mogarick

Description

@mogarick

Hi,
I'm trying to run the Hello Mobile Example for a new create-react-app with react-native-web installed but I'm getting the following error:

Failed to compile.

Error in ./~/react-native-tab-view/src/TabViewAnimated.js
Module parse failed: /Users/xxxxxxx/reactnavcp/node_modules/react-native-tab-view/src/TabViewAnimated.j
s Unexpected token (11:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (11:12)
 @ ./~/react-native-tab-view/index.js 5:33-65

Error in ./~/react-native-tab-view/src/TabViewPagerPan.js
Module parse failed: /Users/xxxxxxx/reactnavcp/node_modules/react-native-tab-view/src/TabViewPagerPan.j
s Unexpected token (13:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (13:12)
 @ ./~/react-native-tab-view/index.js 6:33-65

Error in ./~/react-native-tab-view/src/TabViewPagerScroll.js
Module parse failed: /Users/xxxxxxx/reactnavcp/node_modules/react-native-tab-view/src/TabViewPagerScrol
l.js Unexpected token (10:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (10:12)
 @ ./~/react-native-tab-view/index.js 7:36-71

Error in ./~/react-native-tab-view/src/TabViewPagerAndroid.js
Module parse failed: /Users/xxxxxxx/reactnavcp/node_modules/react-native-tab-view/src/TabViewPagerAndro
id.js Unexpected token (10:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (10:12)
 @ ./~/react-native-tab-view/index.js 8:37-73

Error in ./~/react-native-tab-view/src/TabBar.js
Module parse failed: /Users/xxxxxxx/reactnavcp/node_modules/react-native-tab-view/src/TabBar.js Unexpec
ted token (13:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (13:12)
 @ ./~/react-native-tab-view/index.js 9:24-47

I opened the first file mentioned in the error trace (TabViewAnimated (11:12)) and the problem looks related to Flow:

import type { Scene, SceneRendererProps } from './TabViewTypeDefinitions';

My VSCode indicates the error for the line as [js] 'import ... =' can only be used in a .ts file. for the import type { part of the line.

Is there anything additional to setup for adding support for Flow?

I can see in the node_modules that fbjs is installed which has flow inside.

Just in case, this is the code for the App.js (you can note I modified the import as mentioned in #423 because that was the first error I got)

import React from 'react';
import {
  AppRegistry,
  Text,
} from 'react-native';
import { StackNavigator } from 'react-navigation/lib/react-navigation';

class HomeScreen extends React.Component {
  static navigationOptions = {
    title: 'Welcome',
  };
  render() {
    return <Text>Hello, Navigation!</Text>;
  }
}

const SimpleApp = StackNavigator({
  Home: { screen: HomeScreen },
});

// AppRegistry.registerComponent('SimpleApp', () => SimpleApp);

export default HomeScreen;

Is it something I'm missing or a bug?

My setup process was:

  1. create-react-app myapp
  2. npm install "react-native-web"
  3. npm install "react-navigation" (Got 2 warnings:
    warning "react-native-tab-view@0.0.56" has unmet peer dependency "react-native@".
    warning "react-navigation@1.0.0-beta.6" has unmet peer dependency "react-native@
    ".)
  4. npm start

Thank you in advance for the help.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions