6

After running npm install then npm update I got this error when using ng serve:

Could not find module "@angular-devkit/build-angular" from "C:\\Users\\Matt\\Coding\\chart".
Error: Could not find module "@angular-devkit/build-angular" from "C:\\Users\\Matt\\Coding\\chart".

Then checking the angular version, build-angular is there.

ng version

--

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.11.0 (cli-only)
@angular-devkit/build-angular      <error>
@angular-devkit/build-ng-packagr   <error>
@angular-devkit/core               7.1.0 (cli-only)
@angular-devkit/schematics         7.1.0 (cli-only)
@schematics/angular                7.1.0 (cli-only)
@schematics/update                 0.11.0 (cli-only)
ng-packagr                         <error>
rxjs                               6.3.3 (cli-only)
typescript                         3.1.6 (cli-only)
4
  • I think that this can solve your problem stackoverflow.com/questions/50333003/… Commented Dec 4, 2018 at 8:28
  • i tried the suggestions in that question Commented Dec 4, 2018 at 8:37
  • Did you try installing the missing dependency ? npm i @angular-devkit/build-angular Commented Dec 4, 2018 at 8:49
  • i got the same error and tried ng update --all Commented Jan 17, 2019 at 19:55

4 Answers 4

3

I have the same error. I fixed with follow commands:

  1. install build-angular with this command:

      `npm i --save-dev @angular-devkit/build-angular`
    
  2. then install build-ng-packagr:

      `npm i --save-dev @angular-devkit/build-ng-packagr`
    
  3. finally install ng-packagr:

      `npm i --save-dev ng-packagr`
    

note: the version of installed package will be related with angular version.

I hope is useful.

Sign up to request clarification or add additional context in comments.

Comments

2

What worked for me was uninstall my @angular/cli , then removed node_modules directory and package-lock.json file, then reinstall @angular/cli. Example:

#npm uninstall  @angular/[email protected]
#rm -rf node_modules
#rm package-lock.json
#npm install  @angular/[email protected]

2 Comments

Would you lilke to improve this answer by adding more explanation and maybe some details on "How?". Think of the beginners who might want to use your advice.
package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates. Source: docs.npmjs.com/files/package-lock.json
0

Try this npm install --save-dev @angular-devkit/build-angular

Comments

-1

Haven't you seen these two lines?

@angular-devkit/build-angular      <error>
@angular-devkit/build-ng-packagr   <error>

I encountered similar issues today and solved by npm uninstall @angular/[email protected]; just that, nothing more and then I can run ng build --prod --stats-json as expected.


Before uninstallation, there is the error similar to yours but mine is @angular-devkit/build-ng-packagr.

$ ng build --stats-json
Could not find module "@angular-devkit/build-ng-packagr" from "/home/hearen/git/repos/ng-hue-lib".
Error: Could not find module "@angular-devkit/build-ng-packagr" from "/home/hearen/git/repos/ng-hue-lib".
    at Object.resolve (/home/hearen/git/repos/ng-hue-lib/node_modules/@angular-devkit/core/node/resolve.js:141:11)
    at Observable.rxjs_1.Observable [as _subscribe] (/home/hearen/git/repos/ng-hue-lib/node_modules/@angular-devkit/architect/src/architect-legacy.js:153:40)
    at Observable._trySubscribe (/home/hearen/git/repos/ng-hue-lib/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:44:25)
    at Observable.subscribe (/home/hearen/git/repos/ng-hue-lib/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:30:22)
    at /home/hearen/git/repos/ng-hue-lib/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:99:19
    at new Promise (<anonymous>)
    at Observable.toPromise (/home/hearen/git/repos/ng-hue-lib/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:97:16)
    at BuildCommand.initialize (/home/hearen/git/repos/ng-hue-lib/node_modules/@angular/cli/models/architect-command.js:67:96)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)

...

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.13.8
@angular-devkit/build-angular      0.13.8
@angular-devkit/build-ng-packagr   <error>
@angular-devkit/build-optimizer    0.13.8
@angular-devkit/build-webpack      0.13.8
@angular-devkit/core               7.3.8
@angular-devkit/schematics         7.3.8
@angular/cdk                       7.3.7
@angular/cli                       7.3.8
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.3.8
@schematics/angular                7.3.8
@schematics/update                 0.13.8
ng-packagr                         5.0.1
rxjs                               6.4.0
typescript                         3.1.6
webpack                            4.29.0

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.