问题
I have deleted npm and node. In addition, I have deleted and restored homebrew. I downloaded npm and node from the online download site to restore them. I also downloaded the angular cli through npm. I located my desktop through the terminal and typed
ng new mag-board
to begin my angular project. I was prompted with the following error:
Schematic "ng-new" not found in collection "@schematics/angular".
Error: Schematic "ng-new" not found in collection "@schematics/angular".
at SchematicEngine.createSchematic (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:232:23)
at CollectionImpl.createSchematic (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:69:29)
at NewCommand.getSchematic (/usr/local/lib/node_modules/@angular/cli/models/schematic-command.js:130:27)
at NewCommand.initialize (/usr/local/lib/node_modules/@angular/cli/models/schematic-command.js:43:36)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
I Deleted npm, Deleted node, and I Deleted Angular CLI
I reinstalled npm, node, and Angular CLI
I should be able to generate an Angular project from typing ng new mag-board
回答1:
You can find the answer in https://github.com/angular/angular-cli/issues/10862
I'll short it for you:
first option:
sudo npm uninstall @schematics/angular
and
sudo npm i @schematics/angular
if it's not wroking, then:
Remove the node_modules folder in your home directory.
回答2:
Try this command in angular Command prompt :
npm install @schematics/angular updated
if this doesn't work try uninstall and install @angula/cli. Here's the command for installing and uninstalling angular-cli
npm uninstall @angular/cli
npm install @angular/cli
then use this command in your angular prompt:
npm install @schematics/angular updated
来源:https://stackoverflow.com/questions/55388612/ng-new-not-found-in-collection-schematics-angular