繁体   English   中英

Angular CLI 与纱线 2 (dlx)

[英]Angular CLI with Yarn 2 (dlx)

我正在尝试使用ng new my-app和 yarn 2 dlx 命令启动新的 Angular 项目。 即获取最新的 Angular CLI 并创建新项目。 我尝试了以下但失败了:

λ yarn dlx --package @angular/cli ng new my-app
yarn run v1.22.4
error Couldn't find a package.json file in "C:\\Users\\sax\\Documents\\devel"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

当我使用npx时,它可以工作:

npx --package @angular/cli ng new my-app

我不明白为什么dlx纱线要求 package.json。 我需要在某处启用浆果吗? 有什么方法可以立即使用纱线 2 创建新项目 Angular 吗?

发现需要先在目标目录下设置berry

$ mkdir my-app && cd my-app
$ yarn set version berry
$ yarn dlx --package @angular/cli@next ng new my-app --directory=. --packageManager=yarn

但正如@iesen 已经写的那样——Angular 不支持 Yarn 2,所以我想这不值得麻烦。 I had to use @angular/cli@next just to create project and install dependencies - Angular 9 uses typescript 3.6 which cannot be installed by yarn 2. And then came the issues from github.com/angular/angular-cli/issues/16980 .

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM