Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 CLI error "@angular/compiler-cli" package was not properly installed

I'm working an Angular 2 project. Now trying to install Angular CLI within the current project with the following

npm install --save-dev @angular/cli@latest npm install 

Problem is when running ng serve I receive error

The "@angular/compiler-cli" package was not properly installed. Error: The "@angular/compiler-cli" package was not properly installed.     at Object.<anonymous> (/myng2project/node_modules/@ngtools/webpack/src/index.js:14:11)     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> (/myng2project/node_modules/@angular/cli/tasks/eject.js:10:19)     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) 
like image 561
BrrBr Avatar asked Mar 21 '17 11:03

BrrBr


People also ask

Why angular CLI is not installing?

Try navigating to /usr/local/bin and : if check if the file named ng is present over there, if yes then rm -r ng and it will remove that file. Then you can try sudo npm i -g @angular/cli@latest And it will be a successful install.

What is latest version of angular CLI?

The Angular latest Official stable version is Angular v13. 2.5, which is released on 2nd March 2022.

What is angular compiler?

The Angular Compiler (which we call ngc ) is the tool used to compile Angular applications and libraries. ngc is built on the TypeScript compiler (called tsc ) and extends the process of compiling TypeScript code to add additional code generation related to Angular's capabilities.

Which command is used to install angular CLI?

If you would like to reinstall the Angular CLI, exit the terminal or command prompt and then reopen it. Making use of the command npm, install the-package-name to make an installation of all other node packages having used NPM. It will be placed in the node_modules directory after that.


2 Answers

I had the same problem. I resolved it following the "Updating Angular CLI" process in the npm @angular/cli page, that is:

1. Uninstall and clean (global)

rm -rf node_modules dist npm uninstall -g @angular/cli npm cache clean 

2. Reinstall and play (global)

npm install -g @angular/cli@latest npm install ng serve 

This worked for me.

like image 179
ruzenhack Avatar answered Sep 28 '22 06:09

ruzenhack


I've tried everything in these answers and the only thing that worked for me was the following:

Step 1: npm install -g @angular/cli@latest
Step 2: ng new name-of-project (ignore if project already created)
Step 3: cd name-of-project (ignore if project already created)
Step 4: npm install @angular/cli --save-dev
Step 5: npm install @angular/compiler-cli --save-dev
Step 6: ng serve

Tested these steps in two different environments

Inside of project folder, type "npm install" and wait the installation finishes, this fix works fine for me.

like image 29
LOTUSMS Avatar answered Sep 28 '22 07:09

LOTUSMS