【问题标题】:Cannot run gatsby develop - There was a problem loading the local develop command无法运行 gatsby develop - 加载本地开发命令时出现问题
【发布时间】:2021-03-16 19:43:33
【问题描述】:

我正在尝试运行 gatsby develop 以启动开发服务器,但出现以下错误:

There was a problem loading the local develop command. Gatsby may not be installed in your site's "node_modules" directory. Perhaps you need to run "npm install"? You might need to delete your "package-lock.json" as well.

这是我正在进行的项目:https://github.com/andreiprv/andyprv-blog

从这个 repo 克隆:https://github.com/alxshelepenok/gatsby-starter-lumen

这可能是一个依赖问题,但我不知道如何解决它。在我使用 gatsby new 等启动项目后,出现以下错误:

    npm ERR! code ERESOLVE
    npm ERR! ERESOLVE unable to resolve dependency tree
    npm ERR!
    npm ERR! While resolving: gatsby-starter-lumen@3.0.7
    npm ERR! Found: react@17.0.1
    npm ERR! node_modules/react
    npm ERR!   react@"^17.0.1" from the root project
    npm ERR!
    npm ERR! Could not resolve dependency:
    npm ERR! peer react@"^16.4.2" from gatsby@2.28.0
    npm ERR! node_modules/gatsby
    npm ERR!   gatsby@"^2.27.4" from the root project
    npm ERR!   peer gatsby@"*" from @sentry/gatsby@5.28.0
    npm ERR!   node_modules/@sentry/gatsby
    npm ERR!     @sentry/gatsby@"^5.27.6" 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/andreismbp/.npm/eresolve-report.txt for a full report.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/andreismbp/.npm/_logs/2020-12-04T17_22_00_512Z-debug.log
    error Command failed with exit code 1: npm install
    
    
      Error: Command failed with exit code 1: npm install
    
      - error.js:56 makeError
        [lib]/[gatsby-cli]/[execa]/lib/error.js:56:11
    
      - index.js:114 handlePromise
        [lib]/[gatsby-cli]/[execa]/index.js:114:26
    
      - task_queues:93 processTicksAndRejections
        node:internal/process/task_queues:93:5
    
      - init-starter.js:135 install
        [lib]/[gatsby-cli]/lib/init-starter.js:135:7
    
      - init-starter.js:202 clone
        [lib]/[gatsby-cli]/lib/init-starter.js:202:3
    
      - init-starter.js:343 initStarter
        [lib]/[gatsby-cli]/lib/init-starter.js:343:5
    
      - create-cli.js:449
        [lib]/[gatsby-cli]/lib/create-cli.js:449:9

我尝试使用npm uninstall --save gatsby && npm install --save gatsby再次卸载和安装 gatsby

但它失败并出现以下错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: gatsby-starter-lumen@3.0.7
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.4.2" from gatsby@2.28.0
npm ERR! node_modules/gatsby
npm ERR!   peer gatsby@"*" from @sentry/gatsby@5.28.0
npm ERR!   node_modules/@sentry/gatsby
npm ERR!     @sentry/gatsby@"^5.27.6" 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/andreismbp/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/andreismbp/.npm/_logs/2020-12-04T17_51_08_843Z-debug.log

提前谢谢你!

【问题讨论】:

    标签: reactjs gatsby


    【解决方案1】:

    不确定这是否相关,我遇到了类似的问题,但我的问题是由于我的节点版本与某个库正在使用的版本之间的依赖关系不匹配引起的,因此在更改为另一个版本后它对我有用。

    我注意到运行npm install --loglevel verbose时出错

    看看你能不能得到更多的信息。

    【讨论】:

      【解决方案2】:

      我已经通过运行yarn install 而不是npm install 解决了这个问题

      【讨论】:

      • 这对我有用,我不知道为什么yarn install 有效而npm install 无效。我尝试了quze的答案,但没有奏效。
      【解决方案3】:

      执行以下操作,运行npm install --legacy-peer-deps

      然后在运行gatsby develop 时遇到另一个错误:

      Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (88)
      For more information on which environments are supported please see:
      https://github.com/sass/node-sass/releases/tag/v4.14.1
      error undefined failed
      

      通过将节点降级到 v14.15.1 来修复上述问题。之后我需要运行npm rebuild node-sass

      【讨论】:

      • 不知何故这个解决方案对我有用。还在想怎么来
      • 这对我也有用,不知道为什么!
      猜你喜欢
      • 2018-11-13
      • 2019-06-21
      • 1970-01-01
      • 1970-01-01
      • 2020-06-22
      • 2011-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多