Home > Mobile >  how do you clone a git Gatsby project and run it locally?
how do you clone a git Gatsby project and run it locally?

Time:12-20

I'm familiar with cloning git projects. But I'm struggling to clone a Gatsby project, https://github.com/MunifTanjim/gatsby-theme-dox, and then run the website locally.

I run git clone https://github.com/MunifTanjim/gatsby-theme-dox

Then it downloads

I go into the correct directly, and I've tried gatsby build

This works then gatsby develop

I get the following error:

ERROR gatsby <develop> 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've also tried I also cd into the demo folder and run the same -- I get it to run locally but with a 404 error...

Is it possible to run the demo of this gatsby project?

I'm quite new to Gatsby so trying to understand by starting with a prebuilt project.

CodePudding user response:

Once you clone the repository you need to install the dependencies. cd to the root of your project and run npm install or yarn install.

gatsby build and gatsby develop, like all Gatsby commands, must be run in the root of your project, where the package.json is located. Otherwise, it will throw an exception.

In your case, run the following in order:

git clone https://github.com/MunifTanjim/gatsby-theme-dox
cd gatsby-theme-dox
npm install #or yarn install
gatsby develop #to build the site in development mode
gatsby build && gatsby serve #to build the site in production mode

I'd suggest taking a look at Gatsby commands (gatsby-cli) to understand what you are running.

  • Related