安装strapi遇到的坑

182 阅读1分钟

Logo.WhiteBackground.jpg

Strapi 项目可以安装在本地计算机上或远程服务器上。

在安装 Strapi 之前,电脑上必须安装以下要求:

DatabaseMinimumRecommended
MySQL5.7.88.0
MariaDB10.310.6
PostgreSQL11.014.0
SQLite33

1.开始安装

yarn create strapi-app my-project
# 'yarn create' creates a new project
# 'strapi-app' is the Strapi package
# 'my-project' is the name of your Strapi project

2.选择安装类型

-   `Quickstart (recommended)`,使用默认数据库(SQLite)
-   `Custom (manual settings)`,允许选择你喜欢的数据库
CLI 安装选项

上述安装指南仅涵盖使用 CLI 的基本安装选项。创建新的 Strapi 项目时还可以使用其他选项,例如:

  • --quickstart:直接以快速启动方式创建项目。
  • --template:使用预制 Strapi 配置创建项目(参见 模板)。
  • --typescript/--ts:在 TypeScript 年创建一个项目。
  • --no-run:防止 Strapi 自动启动服务器(与 --quickstart 结合使用)。
  • --skip-cloud:自动回答 "跳过" 的登录/注册问题,以防止安装脚本登录 Strapi Cloud(与 --quickstart 结合使用很有用)。

遇到的问题

再安装依赖的过程中下载 sharp 包一直报错

解决办法

# 在终端执行
yarn config set sharp_binary_host "https://npmmirror.com/mirrors/sharp"

# 回车后执行
yarn config set sharp_libvips_binary_host "https://npmmirror.com/mirrors/sharp-libvips"

# 全局安装
yarn global add sharp

重新再安装依赖完美解决!