'ng new my-app' error

2020-03-07 05:11发布

问题:

I am trying to generate a new project and skeleton application using the latest version of Angular. I have tried uninstalling and reinstalling Angular CLI using:

C:\>npm install -g @angular/cli@latest
C:\>ng --version

@angular/cli: 1.4.5
node: 8.8.1
os: win32 x64

This error occurs when trying to run 'ng new my-app' in command prompt:

'Error: The command "new" has an option without the required type and name field'

Any help to resolve this issue is appreciated.

回答1:

This is a known issue and there is an issue raised in github for this.

https://github.com/angular/angular-cli/issues/7984

Try below commands:

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest


回答2:

After these steps:

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest

Do:

npm install @schematics/angular

And then:

ng new appname