📌  相关文章
📜  gatsby js install - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:15:13.443000             🧑  作者: Mango

Gatsby JS Install - Shell/Bash

Gatsby JS is a popular React-based static site generator. In order to start using Gatsby, you must first install it. This can be done using the 'gatsby-cli' package which can be downloaded and installed as a global package using 'npm'.

Prerequisites for Gatsby JS installation

Before installing Gatsby JS, you should have the following prerequisites installed on your machine:

  • Node.js (version 8.0 or above)
  • npm (version 5.2 or above)
Steps to install Gatsby JS using 'gatsby-cli'

Follow these steps to install Gatsby JS using the 'gatsby-cli' package:

Step 1. Install 'gatsby-cli' globally using 'npm'

Open the terminal and run the following command to install the 'gatsby-cli' package globally:

npm install -g gatsby-cli
Step 2. Create a new Gatsby site

Once 'gatsby-cli' is installed, you can create a new Gatsby site using the 'gatsby new' command followed by your project name.

gatsby new my-gatsby-site

This command will create a new Gatsby site with the name 'my-gatsby-site'.

Step 3. Change directory to your new Gatsby site
cd my-gatsby-site
Step 4. Start up your Gatsby site

Now we can run our site with this command:

gatsby develop
Step 5. Open the site in your browser

Once the Gatsby server has started up you can view your site in your browser at 'http://localhost:8000/'

Conclusion

Installing Gatsby JS and creating a new Gatsby site is fairly straightforward. By following the steps outlined above, you can quickly and easily install Gatsby and start building your static site.