Strapi下载安装慢#报错失败总结带解决代码(已成功)

2024/11/27总结分享        (11/23晚开始安装1h ,24不停改报错/查资料2h ,25晚30m成功)

以下是一篇Strapi安装过程的问题总结:

一、准备事项        

#可能导致安装失败原因

依赖不全/工具版本太低/下载路径不对/网络不稳定/防火墙/端口问题

防火墙/工具版本太低(导致我最开始一直失败的原因)

1.安装失败先检查所有依赖:
-Node.js环境(建议版本 >= 14)【推荐使用最新版】        #node -v

-包管理工具(npm/npx/yarn)                                             #npm -v  #yarn -v

-Python         #Python --version

-Git                #git --version

#cmd命令如果返回版本号,即表示已正确安装对应工具

2.在编辑环境变量窗口:查看Path路径是否包括

-Node.js

-Python

-Git

3.控制面板关闭防火墙!!!(公用网络+专用网络)

4.有VPN/代理 建议使用        #安装过程更加稳定,成功率更高

5.注意安装文件路径中最好不要含有中文字符

        eg.E:\Strapi\projects        #可行

二、创建Strapi项目及镜像配置指令

安装选项:
        安装类型:
        - Quickstart (recommended)

数据库:
        - SQLite (default)
        - MySQL

镜像源指令

常用镜像地址:
        (1)淘宝镜像:https://registry.npmmirror.com
        (2)官方镜像:https://registry.npmjs.org
使用镜像源指令:
(1)切换到淘宝镜像:npm config set registry https://registry.npmmirror.com
(2)或使用cnpm:npm install -g cnpm --registry=https://registry.npmmirror.com
(3)或使用npx:npx create-strapi-app@latest my-project   #本质上就是npm命令
(4)或使用yarn:yarn create strapi-app my-project

启动项目:
        进入项目目录:cd my-project

实际操作举例

-cmd.exe

Microsoft Windows [版本 10.0.22000.2538]
(c) Microsoft Corporation。保留所有权利。

C:\Users\admin>E:

E:\>cd Strapi

E:\Strapi>cd Projects

E:\Strapi\projects>npm config get registry
https://registry.npmmirror.com

E:\Strapi\projects>npx create-strapi-app@latest my-project --quickstart --us
e-npm
Strapiv5.4.1 ? Let's create your new project
We can't find any auth credentials in your Strapi config.
Create a free account on Strapi Cloud and benefit from:
← Blazing-fast ← deployment for your projects
+ Exclusive + access to resources to make your project successful
An ← Awesome ← community and full enjoyment of Strapi' s ecosystem
Start your 14-day free trial now!
 Please log in or sign up. (Use arrow keys)
? Please log in or sign up. Login/Sign up

#回车 跟随指引登录/注册账号

#没有报错等待一会儿 项目创建成功 会自动打开Strapi页面

#以下为部分截图

#注册

成功!!!!!!!!!!!

三、常见问题解决


1.长时间加载


- 清除缓存:npm cache clean --force
- 删除node_modules:rm -rf node_modules(建议直接手动在文件夹删除)
- 重新安装:npm install

#淘宝/官方镜像源都可以试试

#npm/npx/yarn一个不行多试几个

#注意观察报错信息!!!防火墙/工具版本太低(导致我最开始一直失败的原因)

2.端口占用


- 修改config/server.js中的端口配置

3. Sharp Error

可以先单独安装sharp依赖

(1)使用npm:npm install sharp

(2)使用yarn:yarn add sharp

(3)使用cnpm:cnpm install sharp

没有报错再,安装全部依赖

(1)使用npm:npm install

(2)使用yarn:yarn install

(3)使用cnpm:cnpm install

4.Proxychains

如果都不行,可以试试下载Proxychains

#proxychains curl google.com

有回复说明下载成功

去Strapi目录,即可在每行命令前都加上proxychains。

eg.#proxychains yarn install

注意事项


(1)保持网络稳定
(2)使用稳定版本
(3)注意权限问题
(4)记录错误信息
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值