How to update sitemap automatically in React js [duplicate] - reactjs

This question already has answers here:
How to generate sitemap with react router
(2 answers)
Closed 2 years ago.
I am using react-router-sitemap to generate sitemap.xml and successfully generated file in public folder after running npm run sitemap. But I need to update this file whenever I add new URL's to the site without creating build.
I am using python/Django for backend
I followed this blog how to generate sitemap for react website
Is there any way by which I can run npm run sitemap after some conditions

It really depends what the conditions are that you're looking to trigger the command, the blog post you linked actually gives a good way to do this, if you scroll down to the end of the blog post it mentions using a predeploy hook;
"scripts": {
"predeploy": "npm run sitemap"
}
using this predeploy hook will run npm run sitemap before it runs npm run deploy whenever you deploy your application, assuming you deploy your application by running npm run deploy and assuming there's also a deploy script in your package.json

Related

Unable to deploy React app on gh-pages. Getting error: "EN0ENT: no such file or directory, stat '/Users/.../Desktop/home/.git"

I cloned a group project I took part in from github. I am trying to deploy it via gh-pages to add the link to my portfolio. I followed the steps from https://github.com/gitname/react-gh-pages and have successfully deployed a react app from these instructions previously. This is a screenshot of the ENOENT error.EN0ENT error
Below, my package.json is also listed with added predeploy and deploy scripts, as well as the added homepage. package json details
I've tried changing the deploy instructions in package json to
"deploy": "hg-pages -d www"
as seen on a similar stackoverflow post to no avail

How to give next js app build to the client

I am new on Next JS, I have created a small application. It is using API calls and more features.
During development, Using the command as npm run build I am able to create .next folder as build and using npm run start I am able to run that build.
Now the client is asking for build, so what should I send to him? Either complete project and ask him to do the
npm run build and npm run start (which I don't think so)
or only the .next folder. But how he will run this build?
Open package.json in your editor and add the following export script to the file:
"export": "npm run build && next export -o _static"
run this code in the terminal:
npm run export
Open _static folder and there is all of your file.
Some possible ways of sharing your project:
You can easily build and host your project with services like vercel or netlify. Easy and quick. Check out the vercel CLI in particular.
Your client can clone the git repo, install all dependencies, run build, and run start. This'll start a production server. Check here: https://nextjs.org/docs/api-reference/cli#production. Bad idea if your client is not a dev.
You can build your project and send the output to your client, which he/she can then view by spinning up a server (python simpleHTTPServer, Mamp). Also a bad idea if your client is not a dev.
Long story short, host your project somewhere and send them a production URL.

How Do I Modify A deployed react.js project on github?

I am currently learning git, GitHub, and react.js. So, I need to host the react.js project in a GitHub domain. So I did some research and deployed the react.js in the GitHub domain. And I deployed the project successfully by doing these steps :
1.I created a GitHub repository.
2.Then I used this code in Terminal: npm install gh-pages --save-dev
3.Then I add this line in the package.json file:
"homepage":"http://<github-username>.github.io/<repository-name>" and I added this also in the package.json, scripts:
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
after that i added this also in package.json:
"devDependencies": {
"gh-pages": "^3.1.0"
}
4.Then I added remote and committed the code and pushed the code like this:
git remote add origin https://github.com/<github-username>/<repository-name>.git
git add .
git commit -m "initial commit"
git push origin master
5.Then I used this code to deploy the app:npm run deploy
After That Everything was successful and my site hosted as https://<github-username>.github.io/<repository-name>
Then I tried to modify this site, but I can't. When I go to Settings>Pages I found that the deployed branch is gh-pages and this branch wasn't created by me. I changed it back to master and saved it. And when I refreshed the site, there was nothing except the readme.md file. So, I changed it back to gh-pages and it worked again. Then I did some research to modify and I found that I just need to commit and use this code again:npm run deploy
So, I did like That and This Was shown in the Terminal:
> sample#0.1.0 predeploy
> npm run build
> sample#0.1.0 build
> react-scripts build
'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
What's this all about? I need a solution to modify a deployed react.js app.
Anyone Who answers my problem will be appreciated.
Thank you 🙏.
If I'm not wrong to understand your question, here is my little advice.
You just need to add, commit and push your changes to the master repository, and after that run the following step :
npm install
npm run predeploy
npm run deploy
After the steps are success you need to wait several minutes before the changes are live.
Just clone the project and create a new branch.
Modify the project. Then add and commit as usual.
Then use the code git pull
And then type git push <your remote name> <the name of the branch you have created early>
Then go to Github and refresh the page. You will see compare pull request button. Click that. Then add title and description. Then click create new pull request. If your branch is mergable, you will go to another page and you will see merge pull request button and click that.That's all. Then You can delete the branch created by yourself by clicking delete branch safely.
Then use the code npm run deploy
I hope this works 😊.

Need help deploying react application with netlify

Not familiar with how to use netlify. Im trying to deploy this app
https://github.com/Rshauneb/real-estate
my build command is:
npm run watch
but every time I try to deploy my site I keep getting this error.
"failed during stage 'building site'"
Any suggestions?
Mimic what Netlify is doing in the build using their build bot.
Clone your project into a clean directory from GitHub
npm install
npm run watch
If you do not get an error, you may have a global command or setting that does not get set on Netlify. Without more information, this is the only answer possible.
Here is the error I found when I did the above:
Problem #2
Watch is a command for local development, so you should not be using npm run watch as a build command on Netlify. You will need to run the command to build your site into a directory for deploy and use that directory for your "Deploy directory".

Webpack failing to compile till electron is closed

https://github.com/StephenGrider/UpStarMusic/
I cloned the above git repository and was trying to run it after installing dependcies using npm run start
.There is only connection refused error in electron console and the webpack never compiles until the window is closed and once its closed the webpack compiles successfully.
I don't know react was following a tutorial and this was related to MongoDb and for that the tutor was using a react node template to display the data
but am stuck as I cannot move and tried contacting the tutor but he is not responding and after checking git many had this issue .

Resources