[英]How to create Angular 8 project using Angular CLI 9
我正在使用 Angular CLI 9.1.1 但需要使用 Angular 8 創建項目。
我還有其他項目使用 Angular 9,所以我不想全局安裝 Angular 8 CLI。
是否有任何選項可以使用 Angular CLI 9 創建 Angular 8 項目?
您不需要全局安裝 Angular CLI。 它稍微令人厭煩,但肯定比雜耍全球安裝少。 這是程序:
npm init
和npm i @angular/cli@8
。npx ng new myapp
ng new myapp
(或者至少它在我的機器上工作......)
可能你也可以想到npx
。
npx
所做的是它會臨時安裝 nodejs package 然后它會執行它。 因此,這將允許您在本地使用任何版本。
為了實現您的目標,您可以執行以下命令: npx -p @angular/cli@8 ng new <your_project_name>
。 This will create an angular project with version 8 and then you can go to project and use the normal npm
scripts commands from package.json
.
在這種情況下,您不需要全局安裝或降級您的ng
版本。
工具npx預裝npx
npm v5.2.0+
如果有人仍然需要 angular 8 安裝,但使用失敗:
npm i @angular/cli@8
它顯示了這個錯誤:
npm ERR! Could not resolve dependency: npm ERR! peer jasmine-core@">=3.8"
這是修復:
npx ng new myapp --skip-install
cd myapp
Open the package.json and change jasmine-core to `~3.8.0`
npm i
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.