yarn create umi報錯


根據ant-design-pro官網https://pro.ant.design/docs/getting-started-cn的安裝提示,在項目目錄下使用git命令運行yarn create umi,然后報錯,報錯的大概意思就是權限不足,

$ yarn create umi
yarn create v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.11: The platform "win32" is incompatible with this module.
info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "create-umi@0.26.0" with binaries:
- create-umi
error An unexpected error occurred: "EPERM: operation not permitted, unlink 'C:\\Program Files\\nodejs\\node_global\\bin\\create-next-app'".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\86181\\AppData\\Local\\Yarn\\Data\\global\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

 

然后使用管理員權限打開node,切換到目錄下,重新運行yarn create umi,結果又報錯了

D:\genuineadmin>yarn create umi
yarn create v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.11: The platform "win32" is incompatible with this module.
info "fsevents@1.2.11" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...

warning Your current version of Yarn is out of date. The latest version is "1.22.5", while you're on "1.22.4".
info To upgrade, run the following command:
$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
success Installed "create-umi@0.26.0" with binaries:
- create-umi
'C:\Program' 不是內部或外部命令,也不是可運行的程序
或批處理文件。
error Command failed.
Exit code: 1
Command: C:\Program Files\nodejs\node_global\bin\create-umi
Arguments:
Directory: D:\genuineadmin
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

這里提示我的yarn版本低了,先升級yarn版本,可以使用npm i yarn@latest -g來安裝最新版本的yarn

但是升級后再次運行,還是報錯,報錯內容后上面一樣,只是沒報yarn版本的錯誤

在網上搜了下,說修改create-umi.cmd文件路徑,但是我試了一下,修改保存會提示沒有權限

我直接在項目運行create-umi,結果竟然成功了

create-umi
? Select the boilerplate type ant-design-pro
? � Be the first to experience the new umi@3 ? Pro V4
? � Which language do you want to use? TypeScript
? � Do you need all the blocks or a simple scaffold? simple
? � Time to use better, faster and latest antd@4! antd@4
Cloning into 'D:\genuineadmin'...
remote: Enumerating objects: 199, done.
remote: Counting objects: 100% (199/199), done.
remote: Compressing objects: 100% (184/184), done.
remote: Total 199 (delta 30), reused 72 (delta 9), pack-reused 0R Receiv
Receiving objects: 100% (199/199), 300.08 KiB | 165.00 KiB/s, done.
Resolving deltas: 100% (30/30), done.
> � clone success
> Clean up...
✨ File Generate Done

 

然后思考了一下,真正創建項目的命令是create-umi  一開始的yarn create umi其實是全局安裝這個命令,就和我們使用vue-cli需要安裝vue create一樣

如果你也遇到這個問題,不妨試一下分兩步運行命令1. yarn create umi  2.create-umi 注意create-umi中間是橫線連着的

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM