【问题标题】:how do you clone a git Gatsby project and run it locally?你如何克隆一个 git Gatsby 项目并在本地运行它?
【发布时间】:2022-01-21 12:44:51
【问题描述】:

我熟悉克隆 git 项目。 但是我正在努力克隆一个 Gatsby 项目https://github.com/MunifTanjim/gatsby-theme-dox,然后在本地运行该网站。

我跑git clone https://github.com/MunifTanjim/gatsby-theme-dox

然后下载

我直接进入正确的,我试过了 gatsby build

这行得通 然后 gatsby develop

我收到以下错误:

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

我也试过 我还 cd 进入 demo 文件夹并运行相同的 - 我让它在本地运行但出现 404 错误...

可以运行这个 gatsby 项目的演示吗?

我对 Gatsby 还很陌生,所以尝试从预建项目开始理解。

【问题讨论】:

    标签: reactjs gatsby


    【解决方案1】:

    克隆存储库后,您需要安装依赖项。 cd 到项目的根目录并运行 npm installyarn install

    gatsby buildgatsby develop 与所有 Gatsby 命令一样,必须在项目的根目录中运行,package.json 所在的位置。否则会抛出异常。

    在您的情况下,按顺序运行以下命令:

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

    我建议您查看Gatsby commands (gatsby-cli) 以了解您正在运行的内容。

    【讨论】:

      【解决方案2】:
      • git clone https://github.com/MunifTanjim/gatsby-theme-dox.git
      • cd gatsby-theme-dox
      • yarn install
      • cd demo
      • gatsby develop(您应该在 http://localhost:8000/ 中看到主页)或 gatsby build,当它结束时在终端中运行 gatsby serve(参见 http://localhost:9000/ 中的主页)

      【讨论】:

        猜你喜欢
        • 2022-10-16
        • 2023-03-29
        • 2021-06-29
        • 2017-12-19
        • 2018-08-03
        • 2014-12-10
        • 1970-01-01
        • 2019-05-12
        • 2013-11-20
        相关资源
        最近更新 更多