Closed Waterstraal closed 4 years ago
Can you try npx @angular/cli@9 new ng9-app --interactive=false
same result:
"dependencies": {
"@angular/animations": "~10.1.0",
"@angular/common": "~10.1.0",
"@angular/compiler": "~10.1.0",
"@angular/core": "~10.1.0",
"@angular/forms": "~10.1.0",
"@angular/platform-browser": "~10.1.0",
"@angular/platform-browser-dynamic": "~10.1.0",
"@angular/router": "~10.1.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
The -p
option will cause the version specifier to not be used. However, the command suggested above (npx @angular/cli@9 new ng9-app --interactive=false
) should work. If this does not, then one likely cause is that a version of the CLI is installed in the directory hierarchy above the current directory. Could you check if there is an installed instance of the CLI (or potentially a node_modules
directory in or above the current directory)?
Thanks for the information!
I found a node_modules
directory in a direct parent. When I removed it and then ran npx @angular/cli@9 new ng9-app --interactive=false
it installed the expected v9
Regardless, I would expect v9 to be installed with above command wherever I run it, or is this logic flawed somehow?
What's happening here is that at the moment the Angular CLI initialization code will always defer to the "local" installed version in case there is one.
When you use npx
you are essentially install a temporary global version of @angular/cli
, but since you have another "local" @angular/cli
in the directory hierarchy above the current directory the command will be deferred to the latter version.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
π Bug report
Command (mark with an
x
)Is this a regression?
Yes, it used to work in an older version. I'm not sure when I last ran this command, but my best guess is around Angular 6.
Description
Installing a new Angular project using npx and specifying an older @angular/cli@9 version generates an Angular 10 project.
π¬ Minimal Reproduction
Run
npx -p @angular/cli@9 ng new ng9-app --interactive=false
Open
package.json
and see that it installed Angular 10 dependencies:I would expect to see dependencies on version 9.x
π Your Environment
Windows 10 Node.js 12.4.0