Skip to content

安装 AntdDesignPro ​

安装 ​

tsx
npm create umi my-antd-pro-app

做出选择 ​

  • 名字你随便起
bash

> npx
> create-umi my-antd-pro-app

┌   create-umi
│
○  What's the target folder name?
│  demo1
│
○  Pick Umi App Template
│  Ant Design Pro
│
○  Pick Npm Client
│  pnpm
│
○  Pick Npm Registry
│  taobao
│
└  You're all set!

报错 ​

  • 报错信息
bash
[ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: core-js-pure@3.50.0, core-js@3.34.0, es5-ext@0.10.64, esbuild@0.18.20, esbuild@0.28.2
  • 你只需要运行
bash
pnpm approve-builds

启动 ​

  • 安装依赖
bash
npm install

启动项目 ​

bash
npm run start

访问项目 ​

启动成功后,打开浏览器访问:

http://localhost:8000

五、常用命令速查 ​

命令作用
npm run start本地开发启动
npm run build打包生产环境代码
npm run lint代码检查
npm run format格式化代码
npm run tscTypeScript 类型检查

六、常见问题(FAQ) ​

1. npm install 报错或卡住不动 ​

  • 确认已切换到淘宝镜像(见第二步)
  • 删除 node_modules 文件夹和 package-lock.json,重新执行 npm install
  • 尝试使用 tyarn 或 pnpm 安装

2. 端口 8000 被占用 ​

修改 config/config.ts 或通过环境变量指定端口:

bash
set PORT=8001 && npm run start

3. 提示 'npm' 不是内部或外部命令 ​

说明 Node.js 没装好或环境变量未配置,重新安装 Node.js 并重启 cmd。

4. Windows 下 PowerShell 禁止运行脚本 ​

在 PowerShell 中执行 npm 命令报错时,以管理员身份打开 PowerShell,执行:

bash
Set-ExecutionPolicy RemoteSigned

然后输入 Y 确认即可(或改用 cmd 执行命令)。