Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue native is always executing App.js instead of .vue

I made the first process of installation of vue-native, and I'm following the "Getting Started" Hello world tutorial (https://vue-native.io/getting-started.html), but the App.vue is never executed, only the App.js. If I remove the App.js I get an error:

"Unable to resolve "../../App" from "node_modules\expo\AppEntry.js""

How can I fix this problem to make it work and follow the tutorial with any problem?

Folder Structure:

enter image description here

App.js

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

App.vue

<template>
  <view class="container">
    <text class="text-color-primary">My Vue Native App</text>
    </view>
</template>

<style>
.container {
  background-color: white;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.text-color-primary {
  color: blue;
}
</style>

Thank you

like image 284
Bak87 Avatar asked Dec 16 '18 20:12

Bak87


2 Answers

The following worked for me:
At first you delete app.js This will give you an error, but don't worry. You will have to run the npm install command. After this, run vue-native again with npm start

This will run the app.vue file normally

like image 42
Daniel Diaz Avatar answered Sep 21 '22 18:09

Daniel Diaz


Although the answers might work for some. There is another way to fix this issue without deleting any files. Navigate to the node modules folder. Search for the expo folder.

Open the AppEntry.js file. It should look like this:

import 'expo/build/Expo.fx';
import registerRootComponent from 'expo/build/launch/registerRootComponent';
import { activateKeepAwake } from 'expo-keep-awake';

import App from '../../App'; // we will change this!

if (__DEV__) {
  activateKeepAwake();
}

registerRootComponent(App);

Modify Appentry.js to this:

import 'expo/build/Expo.fx';
import registerRootComponent from 'expo/build/launch/registerRootComponent';
import { activateKeepAwake } from 'expo-keep-awake';

import App from '../../App.vue'; // Will use App.vue as the entry point

if (__DEV__) {
  activateKeepAwake();
}

registerRootComponent(App);
like image 69
Umang Mistry Avatar answered Sep 18 '22 18:09

Umang Mistry