angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Error: ngCompiler.ReflectorHost is not a constructor

Open paulocoutinhox opened this issue 10 years ago • 47 comments

Please provide us with the following information:

OS?

Mac OSX (Sierra)

Versions.

ngtools/webpack - 1.1.7

Repro steps.

git clone github.com/prsolucoes/angular2-starter-project cd angular2-starter-project npm install npm start

The log given by the failure.

paulo@MacBook-Pro-de-Paulo:~/Developer/workspaces/node/angular2-starter-project (master) $ npm start

> [email protected] start /Users/paulo/Developer/workspaces/node/angular2-starter-project
> npm run ngc && concurrently -r "webpack-dev-server --config webpack.config.js" "node ./bin/ngc-watch.js"


> [email protected] ngc /Users/paulo/Developer/workspaces/node/angular2-starter-project
> ngc -p ./tsconfig.json

/Users/paulo/Developer/workspaces/node/angular2-starter-project/node_modules/@ngtools/webpack/src/plugin.js:127
        this._reflectorHost = new ngCompiler.ReflectorHost(this._program, this._compilerHost, this._angularCompilerOptions);
                              ^

TypeError: ngCompiler.ReflectorHost is not a constructor
    at AotPlugin._setupOptions (/Users/paulo/Developer/workspaces/node/angular2-starter-project/node_modules/@ngtools/webpack/src/plugin.js:127:31)
    at new AotPlugin (/Users/paulo/Developer/workspaces/node/angular2-starter-project/node_modules/@ngtools/webpack/src/plugin.js:35:14)
    at Object.<anonymous> (/Users/paulo/Developer/workspaces/node/angular2-starter-project/webpack/plugins.js:12:2)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/paulo/Developer/workspaces/node/angular2-starter-project/webpack.config.js:15:11)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)

Mention any other details that might be useful.

My repository with the current problem: https://github.com/prsolucoes/angular2-starter-project

My plugin initialization:

let ngtools = require('@ngtools/webpack');
module.exports = [
	new ngtools.AotPlugin({
		tsConfigPath: './tsconfig.json',
		baseDir: path.join(process.cwd(), 'src'),
		entryModule: path.join(process.cwd(), 'src', 'app', 'modules', 'app.module') + '#AppModule'
	}),
....

paulocoutinhox avatar Nov 22 '16 23:11 paulocoutinhox

I think this is due to the angular 2.2.2 moving ReflectorHost to @angular/language-service.

As a temporary workaround, I've locked my versions to 2.2.1 for @angular/*, 3.2.1 for @angular/router, 2.0.10 for typescript and everything seems to be building fine with AoT.

jessezhang91 avatar Nov 23 '16 04:11 jessezhang91

I think you are correct. Because with version 2.2.1 everything is working fine :(

paulocoutinhox avatar Nov 23 '16 04:11 paulocoutinhox

Intermediately fixed by https://github.com/angular/angular-cli/pull/3242, updating to angular-cli to "1.0.0-beta.21" as described here fixes aot compilation for now.

MartinNowak avatar Nov 23 '16 11:11 MartinNowak

Thanks. But i dont use angular-cli. I have backed all angular2 deps to 2.2.1 version until it be solved.

paulocoutinhox avatar Nov 23 '16 13:11 paulocoutinhox

@prsolucoes Yes, we also updated the peer dependency of the webpack plugin. This will be resolved properly in the future (next week, because this week is thanksgiving). In the meantime you have to use Angular v2.2.1. This is unfortunate and we're looking at long term solutions to prevent this in the future.

hansl avatar Nov 23 '16 17:11 hansl

I'm not sure why HanZ closed this. Everything was working perfect for me with angular-cli-b21, this morning i update angular-cli-b22, tried to build, and i was looking at the error in my console. Same error mentioned above. I'm certain this has something to do with minor project configuration impedance, and you might like to call it a bug, no bug has ever stopped me before, so why would this one stop me now? And, no, I'm not rolling back any of dependencies, i keep everything on the bleeding edge.

digimax avatar Dec 03 '16 14:12 digimax

I'm also seeing this issue with angular-cli 1.0.0-beta.22-1 + angular 2.3.0.

colemickens avatar Dec 08 '16 06:12 colemickens

Same here with angular 2.3.0. Please re-open.

alvipeo avatar Dec 08 '16 06:12 alvipeo

Also same problem.

Angular: 2.3.0 CLI: 1.0.0-beta.22-1

stanislavromanov avatar Dec 08 '16 08:12 stanislavromanov

Same with my project too!

Angular: 2.3.0 CLI: 1.0.0-beta.22-1

petercn avatar Dec 08 '16 12:12 petercn

@hansl any news on this

PG2000 avatar Dec 08 '16 12:12 PG2000

For those subscribed to this issue, there's a bit more detail on another issue: https://github.com/angular/angular-cli/issues/3467#issuecomment-265814703

colemickens avatar Dec 08 '16 20:12 colemickens

Angular: 2.3.0 (also tried with 2.2.3) CLI: 1.0.0-beta.22-1 (tried with 22 also)

Same here, I don't think as correct @colemickens said in the other issue that is productive to close the issues when they are still actually issues, because people cannot track internal "tickets" of the team @hansl.

Please re-open or update the subscribers for the process. In our team whoever did an npm install simply cannot work, even if he downgrades.

vapits avatar Dec 09 '16 11:12 vapits

Same issue here.. I can't run my project and getting ngCompiler.ReflectorHost is not a constructor

Using angular-cli": "1.0.0-beta.22-1 and angular 2.3.0

ritox842 avatar Dec 09 '16 19:12 ritox842

Same here with @ngtools/[email protected]

unsafecode avatar Dec 11 '16 09:12 unsafecode

I ran into this problem after updating angular-cli from beta.20-4 to beta.22-1. After running ng init and diffing package.json, I noticed that I had "@angular/compiler-cli" : "^2.2.4" in the dependencies object, and "@angular/compiler-cli" : "2.2.3" in the devDependencies object. I removed the entry from dependencies, and was able to run npm start.

kevinsherman avatar Dec 11 '16 11:12 kevinsherman

@kevinsherman what version of angular are you using?

Nosfistis avatar Dec 11 '16 13:12 Nosfistis

@Miced

"dependencies": {
   "@angular/common": "2.2.3",
   "@angular/compiler": "2.2.3",
   "@angular/core": "2.2.3",
   "@angular/forms": "2.2.3",
   "@angular/http": "2.2.3",
   "@angular/platform-browser": "2.2.3",
   "@angular/platform-browser-dynamic": "2.2.3",
   "@angular/router": "3.2.3",
   "@types/node": "^6.0.51",
   "bootstrap": "^3.3.7",
   "core-js": "^2.4.1",
   "font-awesome": "^4.7.0",
   "ng2-bootstrap": "^1.1.16",
   "rxjs": "5.0.0-beta.12",
   "ts-helpers": "^1.1.1",
   "zone.js": "^0.6.23"
 }

kevinsherman avatar Dec 11 '16 13:12 kevinsherman

Seeing the same problem as above with both 2.2.4 and 2.2.3.

zakdances avatar Dec 12 '16 00:12 zakdances

I was able to get the angular 2.3.0 working downgrading the angular-cli from version [email protected] to version [email protected]. Now the error has gone.

reginaldocmrg avatar Dec 12 '16 13:12 reginaldocmrg