首页 > 解决方案 > 使用 Angular 9 CLI 创建新项目时如何解决纱线问题?

问题描述

我尝试使用 Angular CLI 创建一个新项目,但出现此错误:

yarn is not recognized as internal or external command

这是控制台日志:

C:\Users\sabir>ng new hello-world
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS
CREATE hello-world/angular.json (3606 bytes)
CREATE hello-world/package.json (1287 bytes)
CREATE hello-world/README.md (1027 bytes)
CREATE hello-world/tsconfig.json (489 bytes)
CREATE hello-world/tslint.json (3125 bytes)
CREATE hello-world/.editorconfig (274 bytes)
CREATE hello-world/.gitignore (631 bytes)
CREATE hello-world/browserslist (429 bytes)
CREATE hello-world/karma.conf.js (1023 bytes)
CREATE hello-world/tsconfig.app.json (210 bytes)
CREATE hello-world/tsconfig.spec.json (270 bytes)
CREATE hello-world/src/favicon.ico (948 bytes)
CREATE hello-world/src/index.html (296 bytes)
CREATE hello-world/src/main.ts (372 bytes)
CREATE hello-world/src/polyfills.ts (2835 bytes)
CREATE hello-world/src/styles.css (80 bytes)
CREATE hello-world/src/test.ts (753 bytes)
CREATE hello-world/src/assets/.gitkeep (0 bytes)
CREATE hello-world/src/environments/environment.prod.ts (51 bytes)
CREATE hello-world/src/environments/environment.ts (662 bytes)
CREATE hello-world/src/app/app.module.ts (314 bytes)
CREATE hello-world/src/app/app.component.html (25725 bytes)
CREATE hello-world/src/app/app.component.spec.ts (957 bytes)
CREATE hello-world/src/app/app.component.ts (215 bytes)
CREATE hello-world/src/app/app.component.css (0 bytes)
CREATE hello-world/e2e/protractor.conf.js (808 bytes)
CREATE hello-world/e2e/tsconfig.json (214 bytes)
CREATE hello-world/e2e/src/app.e2e-spec.ts (644 bytes)`enter code here`
CREATE hello-world/e2e/src/app.po.ts (301 bytes)`enter code here`

Installing packages...'yarn' is not recognized as an internal or external command,
operable program or batch file.
× Package install failed, see above.
The Schematic workflow failed. See above.

标签: angular

解决方案


也许你在 angular/cli 中使用 yarn 激活了。试试这个并创建一个新项目:

ng config -g cli.packageManager npm

到时候这个问题就没有了。


推荐阅读