Issue
Error Message
Uncaught SyntaxError: Unexpected token '<'
manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.
Directory Tree
└--.firebase
└--.github
└--workflows
└--firebase-hosting-merge.yml
└--firebase-hosting-pull-request.yml
└--build
└--node_modules
└--public
└--404.html
└--favicon.ico
└--index.html
└--logo192.png
└--logo512.png
└--manifest.json
└--robots.txt
└--src
└--components
└--App.js
└--AuthForm.js
└--Navigation.js
└--Nweet.js
└--NweetFactory.js
└--routes
└--Auth.js
└--Home.js
└--Profile.js
└--Router.js
└--fbase.js
└--index.js
└--styles.css
└--.env
└--.firebaserc
└--.gitignore
└--firebase.json
└--jsconfig.json
└--package.json
└--package-lock.json
└--README.md
manifest.json
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
this is the file but my site rendered index.html file to manifest.json.
build directory also showing same manifest.json
What I try
Thing 1 : block firebase Overwriting index.html file.
this is my index.html file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web Chat Application created using professional technologies"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>MyTwitter</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
Thing 2 : change firebase.json attribute “public”: “public” to “public”: “build” or “./build”
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Thing 3 : add PUBLIC_URL variable to github, and update env to firebase-hosting-merge.yml
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
env:
PUBLIC_URL: ${{vars.PUBLIC_URL}}
name: Deploy to Firebase Hosting on merge
on:
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_MYWEBAPPPROJ_1705B }}
channelId: live
projectId: mywebappproj-1705b
Error on Router.js when I open page locally
[Routes] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>
I find a information, “div should be wrapped to Route”.
But I’m still getting error.
import { HashRouter as Router, Routes, Route } from "react-router-dom";
import Auth from "./Auth";
import Home from "./Home";
import Profile from "./Profile";
import Navigation from "../components/Navigation";
const AppRouter = ({isLoggedIn, userObj, refreshUser}) => {
return (
<Router>
{isLoggedIn && <Navigation userObj={userObj} />}
<Routes>
<Routes path="/" element={
isLoggedIn ? (
<div style={{
maxWidth: 890,
width: "100%",
margin: "0 auto",
marginTop: 80,
display: "flex",
justifyContent: "center",
}}>
<Route exact path="/" element={<Home userObj={userObj}/>} />
<Route exact path="/profile" element={<Profile refreshUser={refreshUser} userObj={userObj} />} />
</div>
) : (
<Route path="/" element={<Auth />} />
)}></Routes>
</Routes>
{/*<Navigate from="*" to="/">*/}
</Router>
);
};
export default AppRouter;
New contributor
BarrelZebra 2149 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.