getting error when run npm start command with gatsby - reactjs

When I run command npm start it's giving me error
ERROR
gatsby develop
Start development server. Watches files, rebuilds, and hot reloads if
something changes
And when I run command gatsby build it's giving me this error:
gatsby can only be run for a gatsby site. Either the current
working directory does not contain a valid package.json or 'gatsby' is
not specified as a dependency
I tried to delete node_modules and install again but still giving me the same error. How can I fix this?

It seems that you are not running the commands in the proper folder.
npm start, gatsby develop or gatsby build must be triggered in the root of your Gatsby project, where the package.json is located.
Share more details about where and how are you trying to run npm start and even your project structure in order to know what's going on.

Related

Cannot run npm run build due to error ".next/status/media/IMG" does not exist

I'm trying to deploy a static react website (nextjs) and I cannot due to the npm run build command not being able to run. I have an image in my public folder and it's saying it doesn't exist. I've never done this before and don't understand the error I'm getting. The github repository is https://github.com/mattmoon00/portfolio-website . I have tried using vercel and netlify and they both gave me the same error. I also cannot run "npm run build" in the terminal on my machine either. Thanks in advance.

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".

Error on running a project after installing a package

I was running my project finely, but I merge my code with other which contain a package called react-modal, after that my code doesn't work. I revert that code from my project, but it doesn't work, I can't even run my project. "cannot read properties of undefined" error is occuring. I upgrade all my packages like webpack, webpack cli etc, but it doesn't helps. What I need to do to run my project?
Well you can do two things here.
First to revert your code back to your latest code before merge.
Run the below command to delete Node_modules npm prune --production
and then run npm install and then build your project.

Adding dependency gives error: 'react-scripts' is not recognized as an internal or external command, operable program or batch file"

Does anyone else get this issue? When i go to create a new project using create-react-app, and i add any dependency to it other than the stock ones, i.e. react-redux, redux, react-router-dom, i get the following error:
'react-scripts' is not recognized as an internal or external command,
operable program or batch file.
I've tried building with different vs of the modules but that proved pointless.
Any advice on why would be amazing. The versions of the modules are the latest ones.
You are getting that error because you node_modules are either not present their or they are not installed properly because when you are trying to start app with
something start
then it runs the start script from package.json so install the node_ modules properly to start the react app.
Run npm install in the project directory where your package.json is
#Aniruddh Agarwal and Strahinja Ajvaz gave me the hint.
I did start to use yarn for a while but for reason a package name couldn't be installed properly with yarn. I switched to npm install and it worked fine. After trying to run the code it failed. I did npm uninstall package and after that tried yarn add package again. It succeded this time (strange) and the application did start as before.

ReactJS - How to deploy the build folder with the proper paths being referenced?

I've just run "npm run build" on a react app built with the create-react-app npm package. The issue now is that all the minified and bundled files and folders are referencing the root folder, when they are in a sub-folder. I've tried changing in index.html but that doesn't seem to work. Help?
#Jason Xu and #Mamdoh Saraireh thank you so very much for responding and attempting to help me.
It seems I am a complete idiot and did not read the full output of the build message. The solution to my problem is to add
"hompage":"./"
into my package.json file before running npm run build

Resources