1
votes

on the React Native app i have an server.js for mySql activities. And i want to import react-native-router-flux inside of this but i'm facing with: SyntaxError: Cannot use import statement outside a module

server.js

import { Actions } from 'react-native-router-flux';
const MySQLEvents = require('@rodrigogs/mysql-events');
const express = require('express');
const mysql = require('mysql');
let bodyParser = require('body-parser');

const program = async () => {
  const dbConfig = {
    host: '',
    port: '',
    user: '',
    password: '',
    database: ''
  }
.
.
.

I've already used the solutions about this error in the internet. However i've got nothing to solve this.

1

1 Answers

0
votes

Since this code is running on the server using Node.js, it will not have the ability to import in that way.

Try:

const { Actions } = require('react-native-router-flux');

However, I don't know what you're going to do with a react router on the server.