issues with npm start - reactjs

Trying to run a React project I haven't touched in a week or so. When I run 'npm start' the project doesn't show up in my browser automatically anymore. My terminal says that it's being served locally. When I pasted in the address, it didn't show up and I received a 'not found' error . After about 5 min I tried again, and now the project shows up on localhost:5000. I am curious though as to why 'npm start' isn't automated like it should be with React. I tried making changes to my project, and the app in my browser isn't responding to any changes I'm making, even with a hard refresh. So far I've tried deleting node_modules and re-installing npm. I haven't found a thread on npm start that addresses this particular issue, so any advice is appreciated.

Okay, figured it out. For some reason the script for running in my
package.json changed to
"start": "serve -s build" I changed it to "react-scripts start" and that seemed to fix the problem. Not really sure what made it change in the first place.

Related

how to run next js project in vs code?

I am doing a next js project with my friend. I want to run the project with vs code but when i run the commmand "yarn start", i get the following error:
There was a problem loading the local develop command. Gatsby may not be installed in your site's "node_modules" directory. Perhaps you
need to run "npm install"? You might need to delete your "package-lock.json" as well.
error Command failed with exit code 1.
I have done every thing to solve the problem but it is still there.I have re installed npm and gatsby.I have node installed but the problem is still there.I dont know how to fix it.Please guide me
I would highly recommend to delete the package-lock.json then navigate to the root folder of the project and run in the terminal "npm i", also make sure that You have created the nextjs project as in the guidance here -> https://nextjs.org/docs/api-reference/create-next-app

Webpack error when "npm start" on my ReactJS project

I'm trying to learn ReactJS. I just upgraded my dependencies' versions. I was using "npm start" command always for run my server. When I try that code I'm getting an annoying error like "webpack 5.65.0 compiled with 2 errors in 769 ms". I couldn't find my errors. I'm not a real developer. I'm just trying to learn and I'm stuck on this issue.
That's really complicated. So, I just want to uninstall Webpack. You can agree or disagree my idea but Webpack is really annoying. I'm really hate about this stupid thing. I didn't make any changes to my codes. I just updated the version of dependencies. Please help me. I couldn't uninstall Webpack and restore my simple and clear error screen that I am used to.

React's webpack is showing up in the console

i have a this little issue.
I have a new laptop, and I decided to do react project.
I installed the Node's stable version, installed the the npm create-react-app globally, and created a new project using this command npx create-react-app tip-calculator.
Everything was set up for me, only deleted a few files on the src folder, and kept the essentials (index.js, app.js and index.css).
My issues, is on my previous laptop, when doing projects, the webpack (is what i think it is) didn't show up in the console, and on the new laptop, it shows, and I would like it removed.
This is a freshly baked react project, so I didn't touch it's code, aside from the files I deleted.
It's not an issue, it's expected behavior by react-scripts because these logs are hardcoded in react-scripts and currently, there are no options for disabling them. You have probably had an older version of create-react-app in your previous laptop which might have not logged this information on the console.
What is really happening is that you are running react-scripts with npm start and react-scripts are logging webpack logs.
There is also this question which is similar to yours about running react-scripts silently.
If you really don't want to see the output you can redirect it to null:
Linux & Mac: npm start > /dev/null
Windows CMD: npm start > null
Windows Powershell: npm start > $null

npm start errors - React.js

I am trying to run a server so I can start coding my website. However, I run "npm start" I have been greeted with errors. The steps to fixing this error are laid out, however, for step three I do not see babel-loader within my package.json. In addition, I am not sure if the npm ERR!(s) I get on the bottom are caused because of the issue on top or another issue in itself.
package.json
"runs" npm ls babel-loader
It looks like you have globally installed babel-loader#8.0.2. See #6, it points to the exact case you have.
Remove it from your home directory and that should fix it.

React production build failed to load

I have built some code with React. During its "development build", npm start at localhost:3000 give me the correct behavior.
However, after npm run build and serve -s build, the site at localhost:5000 give me this error: Can't remove headers after they are sent.
I have tried to take out everything and make it a bare bone project but the error still appears.
I have tried the production build before and this just happened.
Answer:
Nothing serious. I reinstalled serve package and it is now OK. Seems that a recent update to serve (npm i -g serve) got broken and after reinstall serve package, it is now OK.

Resources