【问题标题】:Unable to start a project with Gatsby+Ghost无法使用 Gatsby+Ghost 启动项目
【发布时间】:2021-05-23 23:10:52
【问题描述】:

我是 Gatsby 的新手,我正在尝试基于 Gatsby + Ghost 启动一个项目,但我可以解决这个问题,我立即执行来自 official github page 的命令:

$ gatsby new gatsby-starter-ghost https://github.com/TryGhost/gatsby-starter-ghost.git                              
info Creating new site from git: https://github.com/TryGhost/gatsby-starter-ghost.git

Cloning into 'gatsby-starter-ghost'...
remote: Enumerating objects: 80, done.
remote: Counting objects: 100% (80/80), done.
remote: Compressing objects: 100% (67/67), done.
remote: Total 80 (delta 2), reused 42 (delta 2), pack-reused 0
success Created starter directory layout
info Installing packages...

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: gatsby-starter-ghost@2.0.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.9.0" from @tryghost/helpers-gatsby@1.0.50
npm ERR! node_modules/@tryghost/helpers-gatsby
npm ERR!   @tryghost/helpers-gatsby@"1.0.50" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/mabvmex/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:

 ERROR

Command failed with exit code 1: npm install


  Error: Command failed with exit code 1: npm install

任何帮助将不胜感激。 提前致谢。

【问题讨论】:

    标签: reactjs gatsby ghost-blog


    【解决方案1】:

    根据提示:

    npm ERR! Found: react@17.0.2
    npm ERR! node_modules/react
    npm ERR!   react@"17.0.2" from the root project
    
    npm ERR! Could not resolve dependency:
    npm ERR! peer react@"^16.9.0" from @tryghost/helpers-gatsby@1.0.50
    npm ERR! node_modules/@tryghost/helpers-gatsby
    npm ERR!   @tryghost/helpers-gatsby@"1.0.50" from the root project
    npm ERR!
    npm ERR! Fix the upstream dependency conflict, or retry
    npm ERR! this command with --force, or --legacy-peer-deps
    

    您正在运行 React v17.0.2,这是对所需 React 版本 (^16.9.0) 的重大升级。您应该能够使用当前版本的 React 运行您的项目,但您可能需要通过以下方式安装对等依赖项:

    npm install gatsby@latest --legacy-peer-deps
    

    注意:在运行之前删除 package-locknode_modules 和可能的 .cache 文件夹。

    【讨论】:

    • 谢谢...所以我有了项目目录。在它上面我安装 --legacy-peer-deps 然后是 gatsby+ghost 命令?
    • 首先安装 Gatsby(具有旧版对等依赖项的最新版本),然后运行启动命令
    • 问题继续...我从“损坏”安装中修改了 package.json 并更改了 react 版本。
    猜你喜欢
    • 1970-01-01
    • 2016-12-16
    • 1970-01-01
    • 2014-06-17
    • 2017-10-15
    • 2022-01-12
    • 2020-09-09
    • 2017-10-13
    相关资源
    最近更新 更多