问题描述
我正在尝试从 vercel 安装 Next.js/Preact.js 设置,但出现以下错误:
> npx create-next-app --example using-preact using-preact-app
Need to install the following packages:
create-next-app
Ok to proceed? (y) y
Creating a new Next.js app in /home/somayyah/Documents/using-preact-app.
Downloading files for example using-preact. This might take a moment.
Installing packages. This might take a couple of minutes.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: using-preact@1.0.0
npm ERR! Found: react@0.0.3
npm ERR! node_modules/react
npm ERR! react@"npm:@preact/compat@^0.0.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.6.0 || ^17" from next@10.0.6
npm ERR! node_modules/next
npm ERR! next@"^10.0.0" 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 /home/somayyah/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/somayyah/.npm/_logs/2021-02-13T17_16_32_165Z-debug.log
我尝试在另一个项目中自己设置 Preact,但遇到了同样的问题,我该如何解决?
解决方法
我认为这是一个与 npx 相关的错误。我正在使用 yarn create next-app --example using-preact using-preact-app
并且它已成功安装,但不幸的是,该示例似乎不起作用并引发错误 Could not find module' webpack