Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Running `ng version` outside an Angular project has confusing output

Đang mở
#16,549 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
angular, typescript
Lĩnh vực
cli

Hướng nghiên cứu

Tái hiện hai lệnh ng version trong issue, cả bên trong và bên ngoài services/ng-frontend/, rồi lần theo điểm bắt đầu của lệnh phiên bản Angular CLI. Thay đổi được hoàn tất khi đầu ra bên ngoài một dự án Angular cho biết rõ rằng không phát hiện dự án nào và không khiến các phiên bản toàn cục trông giống như phiên bản của dự án.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area: @angular/cli freq1: low severity1: confusing type: bug/fix

🐞 Bug report

Command
  • update
  • version
Is this a regression?

No

Description

I have a monorepo where I am adding an Angular project. As a result, it exists in a subdirectory. Since many tools (such as ng) expect the project to be the working directory, I often use the pattern (cd path/to/subproject/ && run some tool). The subshell means I'm returned back to my original directory.

This pattern does not play well with ng version and ng update. I was trying to update to version 9 prerelease and saw the following:

$ (cd services/ng-frontend/ && ng update @angular/cli @angular/core --next)
# Successful update...
$ ng version
     _                      _                 ____ _     ___                                            
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|                                           
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |                                            
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |                                            
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|                                           
                |___/                                                                                   
                                                                                                        
                                                                                                        
Angular CLI: 8.3.21                                                                                     
Node: 13.5.0                                                                                            
OS: linux x64                                                                                           
Angular:                                                                                                
...                                                                                                     
                                                                                                        
Package                      Version                                                                    
------------------------------------------------------                                                  
@angular-devkit/architect    0.803.21                                                                   
@angular-devkit/core         8.3.21
@angular-devkit/schematics   8.3.21
@schematics/angular          8.3.21
@schematics/update           0.803.21
rxjs                         6.4.0

This was confusing and made me think the update failed, however the update was actually fine. My mistake here was running ng version in the root of my monorepo, rather than the Angular project. After noticing this I tried:

$ (cd services/ng-frontend/ && ng version)
     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 9.0.0-rc.7
Node: 13.5.0
OS: linux x64

Angular: 9.0.0-rc.7
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-rc.7
@angular-devkit/build-angular     0.900.0-rc.7
@angular-devkit/build-optimizer   0.900.0-rc.7
@angular-devkit/build-webpack     0.900.0-rc.7
@angular-devkit/core              9.0.0-rc.7
@angular-devkit/schematics        9.0.0-rc.7
@ngtools/webpack                  9.0.0-rc.7
@schematics/angular               9.0.0-rc.7
@schematics/update                0.900.0-rc.7
rxjs                              6.5.4
typescript                        3.6.4
webpack                           4.41.2

Which is what I expected post-update.

IMHO this dichotomy is confusing. When the user is in an Angular project, it lists versions of that project. When outside an Angular project, it lists the global versions and it is very easy to look at the wrong one.

I'm not sure what the ideal solution to this problem would be. There could be two different commands, such as an ng global-version and ng project-version, but this might add too much additional complexity to be worth it. Maybe the output could simply be updated to be more clear? Such as having some big red text saying "No Angular project detected at $PWD"?

Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
17 giờ 25 phút
Pull request đã merge (30 ngày)
183

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của angular/angular-cli

Tất cả issue của angular/angular-cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.