Hi,
I am trying to make an app in react but it seems i am unable to start it , here are my steps
-
I run npm init
-
i install react, react-router-dom, express, body-parser
3)I create a server page with below code -
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const router = require('./router/index');
app.use(bodyParser.json(),bodyParser.urlencoded({extended: false}));
app.get('/', router)
app.listen(3000, (err) => console.log('server has started'))
Then to the router folder where i define my routes i create the below index.js file
const express = require('express');
const router = express.Router();
const Home = require('../components/Home');
const About = require('../components/About');
router.get('/', Home);
router.get('/about', About);
module.exports = router;
Then i create the Home and About pages in react in components folder
import React from 'react';
class About extends React.Component{
render(){
return(
<div>
About page
</div>
)
}
}
export default About;
But there i keep getting the error Unexpected Token import, i do not know why i am getting the error,
Am i making the project the right way , kindly guide …
Thanks