installing node_modules with -global flag causing build errors

I have multiple angular projects and I want to install their dependencies globally to let them use the same modules since they sharing the same dependencies.

so I opened one of the project, typed npm i -g and then when i tried to build the project with ng build I got errors.

    An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
- C:[email protected][email protected]js
- C:[email protected][email protected]
- C:[email protected]-command.js
- C:[email protected]mpl.js
- C:[email protected][email protected]
- C:[email protected][email protected]
- C:[email protected]chema.js
- C:[email protected]unner.js
- C:[email protected]
- C:[email protected]
- C:[email protected]
See "C:UsersUSER~1AppDataLocalTempng-gucVYkangular-errors.log" for further details.
  • I’ve added the global node_modules path to the Environment variables, but still this isn’t helped.

maybe I need to some how link between the project and the global node_modules ?

will appreciate your help.

Source: Angular Questions