【发布时间】: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
提前谢谢你!
【问题讨论】: