1

I have updated my global angular version to 14.1.0 and just created a new project
inside my project I tried to do this:

ng g m views/my-module

but the module is not created and this error occurs in terminal:

An unhandled exception occurred: Collection "@schematics/angular" cannot be resolved.
See "/tmp/ng-6nV3EN/angular-errors.log" for further details.

and also when I try to do ng serve another error:

An unhandled exception occurred: Cannot find module 'copy-webpack-plugin'
Require stack:
- /home/muaaz/Projects/task/node_modules/@angular-devkit/build-angular/src/webpack/configs/common.js
- /home/muaaz/Projects/task/node_modules/@angular-devkit/build-angular/src/webpack/configs/index.js
- /home/muaaz/Projects/task/node_modules/@angular-devkit/build-angular/src/builders/dev-server/index.js
- /home/muaaz/Projects/task/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /home/muaaz/Projects/task/node_modules/@angular-devkit/architect/node/index.js
- /home/muaaz/Projects/task/node_modules/@angular/cli/src/command-builder/architect-base-command-module.js
- /home/muaaz/Projects/task/node_modules/@angular/cli/src/command-builder/architect-command-module.js
- /home/muaaz/Projects/task/node_modules/@angular/cli/src/commands/build/cli.js
- /home/muaaz/Projects/task/node_modules/@angular/cli/src/command-builder/command-runner.js
- /home/muaaz/Projects/task/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
See "/tmp/ng-sSdlks/angular-errors.log" for further details.

I tried to clean the npm cache & delete "node_modules" then install again with npm install but that did not work.

any ideas?

muaaz
  • 101
  • 11

1 Answers1

1

Looks like @schematics/angular is not installed as a dev-dependency by default. Try running npm install @schematics/angular --save-dev. This will install the package.

Grochni
  • 1,663
  • 20
  • 25
  • I actually ended installing many dependencies that was missing in my project and they are part of angular, can you explain why the `ng new` command did not install them in the first place?,... sorry for the very late response. – muaaz Aug 07 '22 at 17:02
  • Now that I think about it I guess your globally installed angular version differs from the version specified in you package.json. Try running `npm list -g @angular/cli` to find out your globally installed angular version. To update your global angular installation, you can run `npm update -g @angular/cli`. Let me know if my assumption was correct. If so, I'll update the answer to help others with similar issues. – Grochni Aug 09 '22 at 10:11
  • the global version is 14.1.0 and the one in package.json is the same – muaaz Aug 11 '22 at 21:00