Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [BUG] v5 使用 Yarn 作為包管理器將引致報錯 #10809

Closed
GreenYun opened this issue Jun 23, 2023 · 2 comments
Closed

🐛 [BUG] v5 使用 Yarn 作為包管理器將引致報錯 #10809

GreenYun opened this issue Jun 23, 2023 · 2 comments
Labels

Comments

@GreenYun
Copy link

GreenYun commented Jun 23, 2023

🐛 bug 描述

若在創建新 v5 項目時選用 Yarn 作為 Npm Client 將無法完成安裝,具體報錯是:

Internal Error: root-workspace-0b6124@workspace:.: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile

📷 复现步骤 | Recurrence steps

在 Bash 執行

yarn create umi my-app

選用 Ant Design Pro

Pick Npm Client:
yarn

🏞 期望结果 | Expected results

安裝成功。

💻 复现代码 | Recurrence code

© 版本信息

  • Ant Design Pro 版本: 5
  • umi 版本: 4.0.71
  • 浏览器环境: -
  • 开发环境: macOS 或 Linux
  • Node.js: Current (20.3.1)
  • yarn: 3.6.0

🚑 其他信息

@chenshuai2144
Copy link
Collaborator

TAutomatically replying with ChatGPT can be attempted, but it cannot be guaranteed to be completely accurate and may not fully address all issues. Please feel free to reply if you have any further questions or concerns.
此回复基于 ChatGPT 自动生成,可以尝试下方案,官方人员会在一定时间后继续继续处理。

解决方案

这个问题通常是由于 yarn 版本过低导致的。你可以尝试升级到最新版本的 yarn 来解决这个问题。

首先,按照下面的步骤卸载旧版本的 yarn:

npm uninstall -g yarn

然后,按照下面的步骤安装最新版本的 yarn:

npm install -g yarn

安装完成后,再次尝试创建新的 v5 项目并选择 yarn 作为 Npm Client:

yarn create umi my-app
Pick Npm Client: yarn

这样就应该可以成功完成安装了。

如果问题仍然存在,你可以尝试清除缓存并重新安装依赖项。请尝试以下步骤:

yarn cache clean
yarn install

这将清除 yarn 的缓存并重新安装项目的依赖项。

如果问题仍然没有解决,你还可以尝试使用 npm 作为 Npm Client。请执行以下命令:

yarn create umi my-app
Pick Npm Client: npm

这将使用 npm 作为包管理器来创建项目,这可能会解决你遇到的问题。

希望这些解决方案能帮助你解决问题!如果问题仍然存在,请提供更多信息,我们会尽力提供帮助。

相关文档

@chenshuai2144
Copy link
Collaborator

值得注意是的百分之二十的问题都可以用重装依赖来解决,所以你可以尝试一下:
删除 'node_modules' 文件夹 -> 删除 'package-lock.json'或 'pnpm-lock.yaml' 文件 -> 运行 'pnpm install' 或 'npm install' 命令

这个问题的解决方案是使用tyarn或cnpm来替代yarn作为包管理器。

推荐使用 tyarn 来进行包管理,可以极大地减少安装的时间和失败的概率,并且完全兼容npm。

如果你更喜欢使用npm而不是yarn,可以使用 cnpm,它的安装速度比tyarn更快,但不是完全兼容npm。

以下是使用tyarn的解决方案:

  1. 首先安装tyarn:运行npm install -g tyarn
  2. 使用tyarn创建umi项目:运行tyarn create umi my-app
  3. 选择Ant Design Pro并选择tyarn作为npm客户端。
  4. 运行tyarn install来安装项目依赖。

这样就可以成功安装umi项目了。

如果你选择使用cnpm作为npm客户端,可以按照相同的步骤进行操作,只需将tyarn替换为cnpm即可。

希望这个解决方案对你有帮助!有任何问题请随时提问。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants