I have an application in react and I need to publish it on a windows server with PM2.
My application is working on my machine, but when performing the build and trying to lift it I get the following error:
Uncaught SyntaxError: Unexpected token '<'
I did the following steps:
npm run build
pm2 serve build 3000 --spa
The main file of my project is this:
index.js
import 'core-js'
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import reportWebVitals from './reportWebVitals'
import { Provider } from 'react-redux'
import store from './store'
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root'),
)
reportWebVitals()
My App.js
import React, { Component, Suspense } from 'react'
import { BrowserRouter , Route, Routes, BrowserRouter as Router } from 'react-router-dom'
import AxiosService from '../src/services/axios.service'
import './scss/style.scss'
import './scss/_custom.scss'
AxiosService.Configure();
const DefaultLayout = React.lazy(() => import('./layout/DefaultLayout'))
const Page404 = React.lazy(() => import('./views/pages/page404/Page404'))
const Page500 = React.lazy(() => import('./views/pages/page500/Page500'))
const PageLogin = React.lazy(() => import('./views/pages/login/Login'))
const loading = (
<div className="pt-3 text-center">
<div className="sk-spinner sk-spinner-pulse"></div>
</div>
)
class App extends Component {
render() {
return (
<BrowserRouter>
<Suspense fallback={loading}>
<Routes>
<Route path="*" element={<DefaultLayout />}/>
<Route exact path='/404' element={<Page404/>}/>
<Route exact path='/500' element={<Page500/>}/>
<Route exact path='/login' element={<PageLogin/>}/>
</Routes>
</Suspense>
</BrowserRouter>
)
}
}
export default App
The output folder with index.html:
<!doctype html><html lang="pt-BR"><head><meta charset="utf-8"/><link rel="icon" href="/src/assets/brand/logo_black.ico"/><meta name="view...