Strapi安装过程中依赖安装报错

Posted

技术标签:

【中文标题】Strapi安装过程中依赖安装报错【英文标题】:Getting an error during the dependency installation of Strapi installation process 【发布时间】:2021-04-17 07:45:35 【问题描述】:

最近我尝试使用“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: strapi-app@0.1.0
npm ERR! Found: knex@0.19.5
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 strapi-connector-bookshelf@3.4.1
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

【问题讨论】:

你电脑上安装的node.js是什么版本? 【参考方案1】:

Strapi 显然只支持 Node v14(当前 LTS)。切换到该版本(NVM?),然后重试。

【讨论】:

我是本地人,我有 Node v14.5.0,但遇到与操作相同的错误。【参考方案2】:

我在部署到 heroku 时遇到了同样的问题。 它通过将 package.json 中的 npm 版本从 >=6.0.0 更改为 6.14.9 来工作:

  "engines": 
    "node": ">=10.16.0 <=14.x.x",
    "npm": "6.14.9"
  

【讨论】:

【参考方案3】:

我像这样将我的 nodeJS 引擎版本更改为 v14 并且它起作用了:

  "engines": 
    "node": "14.x",
    "npm": "6.x"
  ,

来源:推荐的版本至少为12,但推荐的版本为14https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/installation/cli.html#step-1-make-sure-requirements-are-met

【讨论】:

以上是关于Strapi安装过程中依赖安装报错的主要内容,如果未能解决你的问题,请参考以下文章

maven项目中添加MySql依赖失败(以及maven的安装到maven项目的使用过程)

MAC系统npm安装依赖,报错npm ERR! code ECONNREFUSED

解决Ansible安装依赖问题

npm i 安装不上依赖怎么办

Nginx安装启动过程报错libpcre.so.1 cannot open shared object file: No such file or directory

sass 安装