7

Upgrading my project to Angular 4.0 (from 2.4) with Angular CLI 1.0 (from beta.31), I get the error below after following the migration guide:

> ng build --prod
The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
 at Object.<anonymous> (/home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/index.js:14:11)
 at Module._compile (module.js:571:32)
 at Object.Module._extensions..js (module.js:580:10)
 at Module.load (module.js:488:32)
 at tryModuleLoad (module.js:447:12)
 at Function.Module._load (module.js:439:3)
 at Module.require (module.js:498:17)
 at require (internal/module.js:20:19)
 at Object.<anonymous> (/home/jan/src/fm-repos/fm-ui/node_modules/@angular/cli/tasks/eject.js:10:19)
 at Module._compile (module.js:571:32)
 at Object.Module._extensions..js (module.js:580:10)
 at Module.load (module.js:488:32)
 at tryModuleLoad (module.js:447:12)
 at Function.Module._load (module.js:439:3)
 at Module.require (module.js:498:17)
 at require (internal/module.js:20:19)

My angular dependencies post-migration:

"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/compiler-cli": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@angular/cli": "1.0.0",
"@angular/material": "2.0.0-beta.3",

Note: this similar question is about Angular 2 project: Angular2 CLI error "@angular/compiler-cli" package was not properly installed

asked Apr 11, 2017 at 16:10
4
  • is your @angular/compiler-cli set to version 4? matching the other angular dependencies? have you tried removing your project's node_modules folder then npm-install? Commented Apr 11, 2017 at 18:51
  • I just tried on my local, I can reproduce this error if I downgrade typescript to less than 2.1.0 version. Please update to typescript 2.2.0 and your issue will be resolved. Commented Apr 11, 2017 at 19:04
  • Indeed, @AhmedMusallam; after the changes in the answer below, everything works! :D Commented Apr 11, 2017 at 19:08
  • ah ok, did not realize you answered your own question :) please accept it when you can, I know you have to wait 24 hours or something :) Commented Apr 11, 2017 at 19:09

10 Answers 10

10

Ensure you have TypeScript 2.2 in your package.json and ensure your tsconfig is properly updated.

Details:

With Angular CLI 1.0 installed, create a new dummy project:

ng new dummy

then remove the node_modules directories:

rm -rf ./dummy/node_modules
rm -rf ./myproject/node_modules

and diff the changes between the dummy project and your project:

diff -bur ./dummy/ ./myproject/

Of the many changes, the crucial change necessary to address this error for me was TypeScript and tsconfig changes:

package.json:

"typescript": "~2.0.3" ==> "typescript": "~2.2.0"

.angular-cli.json

Change:

"tsconfig": "tsconfig.json"

to:

"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",

and add these new files from your dummy project, and install your packages:

npm install
answered Apr 11, 2017 at 16:10
Sign up to request clarification or add additional context in comments.

1 Comment

thanks mate, helpful approach with the dummy project
8

I create new fresh installation in Linux machine _ _ ____ _ _ / \ _ __ __ _ _ _| | __ _ _ __ / | | | | / しろさんかく \ | ' \ / _| | | | |/ _ | '| | | | | | | / \| | | | (| | || | | (| | | | || | | | // __| ||__, |__,||__,|| ____|_____|| |/ @angular/cli: 1.0.1 node: 6.10.2 os: linux x64

Aftere i create new angular 2 project using

ng new angularhellword

Project successfully created but when i execute command

ng serve

Given me above same error like

The "@angular/compiler-cli" package was not properly installed.

Please take the following steps to avoid issues:

"npm uninstall --save-dev angular-cli"

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

It works for me and project run successfully.

answered May 1, 2017 at 5:45

1 Comment

This was by far the easiest solution to this problem, and it worked!
2
npm uninstall -g angular-cli
rm -rf ./node_modules
rm package-lock.json
npm install --save-dev @angular/cli@latest

if installing the latest version still gives you an error you can run through the process again of uninstalling and manually enter the version of angular-cli after verifying the newest release in the angular-cli repo. My package.json listed ^1.3.0, but there was a beta version just released and when i manually changed it to

"@angular/cli": "^1.3.0-beta.0" 
npm i

It installed successfully

answered Jul 5, 2017 at 2:00

Comments

1

For me none of the solutions above worked, but updating npm and typescript globally did.

To update, run these commands:

npm update
npm update -g typescript
answered Jul 16, 2017 at 8:25

Comments

0

I had this same error message on my Mac running OS 10.12.4 when I was setting up Angular 2.

I also had a similar problem on two different Windows 10 machines. The windows machines received an error that stated,

 Node_modules appears empty, you may need to run `npm install`.

In both cases, I was able to solve the problem by running npm install within the project directory.

I went into the command line / terminal and then into the directory where the project was stored, e.g.:

 c:\Users\myname\projectname>

For Windows I used npm install command and in Mac I used sudo npm install.

In both cases it took care of the problem.

Jan Nielsen
12k16 gold badges76 silver badges137 bronze badges
answered Apr 12, 2017 at 22:54

1 Comment

Welcome to SO, Jim. It looks like the second part of your answer "similar problem on two different Windows 10 machines" is a separate problem (despite having the same solution: npm install) which should be a separate SO question.
0

I tried everything, and the only thing that worked for me was a simple npm install

answered Jul 18, 2017 at 1:42

Comments

0

I just changed to "@angular/compiler-cli": "^4.3.2" from "@angular/compiler-cli": "^4.0.0" in devDependencies in package.json file.

It worked for me

answered Aug 4, 2017 at 0:46

Comments

0

This worked Like Magic

npm install --save-dev del

answered Aug 4, 2017 at 17:29

Comments

0

Open package.json and move @angular/cli under dependencies like:

"dependencies": {
 "@angular/animations": "^4.0.0",
 "@angular/common": "^4.0.0",
 "@angular/compiler": "^4.0.0",
 "@angular/cli": "1.2.1",
 "@angular/compiler-cli": "^4.3.1",
 "@angular/core": "^4.0.0",
 "@angular/forms": "^4.0.0",
 "@angular/http": "^4.0.0",
 "@angular/platform-browser": "^4.0.0",
 "@angular/platform-browser-dynamic": "^4.0.0",
 "@angular/router": "^4.0.0",
 "core-js": "^2.4.1",
 "rxjs": "^5.1.0",
 "zone.js": "^0.8.4"
 },

Then go to project folder in command prompt and run the command "npm install". It will load all necessary dependencies.

Eren Tantekin
1,47114 silver badges24 bronze badges
answered Jul 20, 2017 at 3:47

Comments

0

Try these steps please: Clean up

remove node_modules from your project
remove any angular-cli and @angular/cli references from package.json if it's there
Uninstall angular-cli and @angular/cli globally: npm uninstall -g angular-cli @angular/cli

Reinstall

Install @angular/cli globally: npm install -g @angular/cli
Install @angular/cli in your project: npm install --save-dev @angular/cli
answered Oct 13, 2017 at 20:45

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.