Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 views
in Technique[技术] by (71.8m points)

ng new has stopped working after updating to Angular 6

Today, I updated my angular cli to the latest version and encountered an error that stops me from creating a new Angular project. Following is the error log that I get after executing ng new app-name :

Error: Schematic "ng-new" not found in collection "@schematics/angular".
    at SchematicEngine.createSchematic (C:Usersxyz
ode_modules@angularcli
[email protected]:155:23)
    at CollectionImpl.createSchematic (C:Usersxyz
ode_modules@angularcli
[email protected]:12:29)
    at NodeWorkflow.execute (C:Usersxyz
ode_modules@angularcli
ode_modules@angular-devkitschematicsoolsworkflow
ode-workflow.js:70:38)
    at Promise (C:Usersxyz
[email protected]:141:22)
    at new Promise (<anonymous>)
    at NewCommand.runSchematic (C:Usersxyz
[email protected]:140:16)
    at NewCommand.<anonymous> (C:Usersxyz
ode_modules@angularclicommands
ew.js:77:25)
    at Generator.next (<anonymous>)
    at C:Usersxyz
ode_modules@angularclicommands
ew.js:7:71
    at new Promise (<anonymous>)

In order to solve the problem myself I have reinstalled angular cli as well as npm more than twice. The versions of packages are as follows:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.6.0
@angular-devkit/core         0.6.0
@angular-devkit/schematics   0.6.0
@schematics/angular          0.6.0
@schematics/update           0.6.0
rxjs                         6.1.0
Angular Cli                  6.0.0
Node                         8.11.1
npm                          5.6.0

Any help would be appreciated.

Edit: I ran ng new from the place where the angular global packages are installed and I am able to create an an application from there. Running it from anywhere else, produces error.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That happened to me, I thought that was a bug I reported it here, it turned out that I had a folder named node_modules on my home directory!

To make sure this is the same issue with you run following commands

npm ls -g @schematics/angular
npm ls @schematics/angular 

If the output of second command contains

npm ERR! extraneous: @schematics/[email protected] C:UsersUser
ode_modules@angularcli
ode_modules@schematicsangular

then most likely you have the same issue as it appears that there is a node_modules folder with both the CLI and an old version of @schematics/angular installed locally (C:UsersUser). Remove this to fix this issue.

Please check if it is the case for you too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...