问题描述
最近我尝试使用“npx”将 Strapi 安装到我的 Windows 计算机上。但是当依赖项更新如下时我收到一个错误。我尝试卸载并安装 knex 但它没有用。我该如何解决这个问题?
strapi-app>npx create-strapi-app . --quickstart
Creating a new Strapi application at D:\E-LEARNING\React Js\projects\strapi-app.
Creating a quickstart project.
Creating files.
Error while installing dependencies:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/knex
npm ERR! knex@"<0.20.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer knex@"^0.20.0" from [email protected]
npm ERR! node_modules/strapi-connector-bookshelf
npm ERR! strapi-connector-bookshelf@"3.4.1" 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 C:\Users\user\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2021-01-12T10_28_05_191Z-debug.log
Keep trying!
Oh,it seems that you encountered errors while installing dependencies in your project.
Don't give up,your project was created correctly.
Fix the issues mentionned in the installation errors and try to run the following command:
cd D:\E-LEARNING\React Js\projects\strapi-app && npm install
npm ERR! code 1
npm ERR! path D:\E-LEARNING\React Js\projects\strapi-app
npm ERR! command Failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-strapi-app . --quickstart
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2021-01-12T10_28_07_219Z-debug.log
解决方法
Strapi 显然只支持 Node v14(当前的 LTS)。切换到该版本(NVM?)并重试。
,我在部署到 heroku 时遇到了同样的问题。 它的工作原理是将 package.json 中的 npm 版本从 >=6.0.0 更改为 6.14.9:
"engines": {
"node": ">=10.16.0 <=14.x.x","npm": "6.14.9"
}
,
我像这样将我的 nodeJS 引擎版本更改为 v14 并且它有效:
"engines": {
"node": "14.x","npm": "6.x"
},
来源:推荐版本至少为 12,但推荐 14 https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/installation/cli.html#step-1-make-sure-requirements-are-met