Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run new Angular CLI project

I've got a homework assignment for a job interview. It needs to be done in Angular, so I figured I'd quickly upgrade Node.js, NPM and Angular CLI before I start. It looks like that was a bad idea.

After running my command: ng new project-name --style scss everything seems to create itself just fine. But when I run ng serve I'm getting the following error:

Cannot find module 'uglifyjs-webpack-plugin'
Error: Cannot find module 'uglifyjs-webpack-plugin'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/andybarratt/dev/project-name/node_modules/@angular/cli/models/webpack-
configs/production.js:13:24)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/andybarratt/dev/project-name/node_modules/@angular/cli/models/webpack-
configs/index.js:9:10)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)

I can't find anything with this error involving Angular anywhere. As I say, it's a completely clean project; I haven't even begun coding yet.

Running ng --version gives me this:

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

Angular CLI: 1.6.6
Node: 9.4.0
OS: darwin 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

Help?

like image 999
apbarratt Avatar asked Jan 29 '18 19:01

apbarratt


2 Answers

This was just called out on their GitHub account, https://github.com/angular/angular-cli/issues/9427.

Just get an earlier version, and/or fix their issue and put up a pull request (PR).

like image 190
Dylan Wright Avatar answered Nov 01 '22 03:11

Dylan Wright


Add "uglifyjs-webpack-plugin": "1.1.6" to your package.json for now until they fix dependency issue ( https://github.com/angular/angular-cli/issues/9427 )

Also you can use command npm i --save-dev [email protected]instead of edditing package.json manually as @Botonomous and @toughskin mentioned

like image 13
kEpEx Avatar answered Nov 01 '22 02:11

kEpEx