angular-cli: Cannot find module 'uglifyjs-webpack-plugin'

Versions 1.6.6

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.6.6
Node: 6.11.2
OS: win32 x64
Angular: 5.2.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.6
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.6
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0

Repro steps

  • ng new sample
  • cd sample
  • ng serve

Observed behavior

 ng serve
Cannot find module 'uglifyjs-webpack-plugin'
Error: Cannot find module 'uglifyjs-webpack-plugin'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\sample\node_modules\@angular\cli\models\webpack-configs\production.js:13:24)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\sample\node_modules\@angular\cli\models\webpack-configs\index.js:9:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)

Desired behavior

First, I expect this simple project to run. Then I would expect to run ng build --prod on another project

Mention any other details that might be useful (optional)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 9
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Check the version of uglifyjs-webpack-plugin you are using in your package.json. I was using 1.1.7 which broke my build a few hours ago, however, after installing the latest version via npm install --save uglifyjs-webpack-plugin It upgraded to 1.1.8 and now my build is fine…

Also see This post

I’ve been trying to figure this problem out for about an hour, now. I have uninstalled angular and reinstalled it. I wasn’t having this issue earlier and have no idea what could have changed that would cause me to run into this now. Any help would be awesome.

same… 😦