Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: ngCompiler.ReflectorHost is not a constructor #3241

Closed
paulocoutinhox opened this issue Nov 22, 2016 · 47 comments
Closed

Error: ngCompiler.ReflectorHost is not a constructor #3241

paulocoutinhox opened this issue Nov 22, 2016 · 47 comments

Comments

@paulocoutinhox
Copy link

paulocoutinhox commented Nov 22, 2016

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

> angular2-starter-project@1.0.0 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"


> angular2-starter-project@1.0.0 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'
	}),
....

@jessezhang91
Copy link

jessezhang91 commented Nov 23, 2016

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.

@paulocoutinhox
Copy link
Author

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

MartinNowak referenced this issue in angular/angular Nov 23, 2016
Previously, this was part of the `AotCompilerHost`.
The `AotCompilerHost` is now also greatly simplified.
@MartinNowak
Copy link

Intermediately fixed by #3242, updating to angular-cli to "1.0.0-beta.21" as described here fixes aot compilation for now.

MartinNowak added a commit to MartinNowak/alertd that referenced this issue Nov 23, 2016
@paulocoutinhox
Copy link
Author

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

debben added a commit to debben/ng2-admin that referenced this issue Nov 23, 2016
@hansl
Copy link
Contributor

hansl commented Nov 23, 2016

@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 hansl closed this as completed Nov 23, 2016
MartinNowak added a commit to MartinNowak/alertd that referenced this issue Nov 24, 2016
@digimax
Copy link

digimax commented Dec 3, 2016

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.

@colemickens
Copy link

colemickens commented Dec 8, 2016

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

@alvipeo
Copy link

alvipeo commented Dec 8, 2016

Same here with angular 2.3.0. Please re-open.

@stanislavromanov
Copy link

Also same problem.

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

@petercn
Copy link

petercn commented Dec 8, 2016

Same with my project too!

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

@PG2000
Copy link

PG2000 commented Dec 8, 2016

@hansl any news on this

@colemickens
Copy link

For those subscribed to this issue, there's a bit more detail on another issue: #3467 (comment)

@vapits
Copy link

vapits commented Dec 9, 2016

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.

@ritox842
Copy link

ritox842 commented Dec 9, 2016

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

@unsafecode
Copy link

Same here with @ngtools/webpack@1.1.9

@kevinsherman
Copy link

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.

@Nosfistis
Copy link

@kevinsherman what version of angular are you using?

@kevinsherman
Copy link

@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"
 }

@zakdances
Copy link

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

@reginaldocmrg
Copy link

reginaldocmrg commented Dec 12, 2016

I was able to get the angular 2.3.0 working downgrading the angular-cli from version angular-cli@1.0.0-beta.22-1 to version angular-cli@1.0.0-beta.21. Now the error has gone.

@sclausen
Copy link

@reginaldocmrg WOW that worked!

@Adrriver
Copy link

Adrriver commented Dec 12, 2016

How do you actually rollback, though? I performed a global install of angular-cli@1.0.0-beta.21, after global removing 22, and still have .beta22! I feel liked I'm negotiating with a cartoon.

@reginaldocmrg
Copy link

I installed angular-cli@1.0.0-beta.21 locally.

@sclausen
Copy link

@Adrriver it worked well for me

sudo npm uninstall -g angular-cli
sudo npm install -g angular-cli@1.0.0-beta.21

@ritox842
Copy link

@Adrriver solution works for me also...

@mahindar5
Copy link

I'm getting the same error but I'm not using angular-cli. I'm using webpack. My package.json looks like this
{
"version": "1.0.0",
"name": "sample",
"private": true,
"dependencies": {
"@angular/common": "~2.3.0",
"@angular/compiler": "~2.3.0",
"@angular/core": "~2.3.0",
"@angular/forms": "~2.3.0",
"@angular/http": "~2.3.0",
"@angular/platform-browser": "~2.3.0",
"@angular/platform-browser-dynamic": "~2.3.0",
"@angular/router": "~3.3.0",
"angular-in-memory-web-api": "~0.1.17",
"core-js": "^2.4.1",
"ionic-angular": "^2.0.0-rc.3",
"jquery": "^3.1.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-rc.4",
"systemjs": "0.19.40",
"typescript": "^2.1.4",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/compiler-cli": "^2.3.0",
"@ngtools/webpack": "^1.1.9",
"@types/jquery": "^2.0.34",
"angular2-template-loader": "0.6.0",
"html-webpack-plugin": "^2.24.1",
"raw-loader": "^0.5.1",
"ts-loader": "1.3.1",
"webpack": "2.1.0-beta.27"
}
}

@stanislavromanov
Copy link

@mahindar5 Error actually comes from webpack, either you use ng cli or not.

@mahindar5
Copy link

Hi @stanislavromanov is there any workaround to fix this? Thanks

@daviddsingleton
Copy link

Tried all suggested solutions still nothing working.
@angular2.3
@ngtools/webpack 1.1.9

@jessezhang91
Copy link

@daviddsingleton you need angular 2.2.4 (and 3.2.4 for router)

@alorle
Copy link

alorle commented Dec 16, 2016

Same issue here with 1.0.0-beta.23, as in (#3501, #3467 and #3367). Besides the problem building, I do not know why UNMET PEER DEPENDENCY message when installing latest CLI release.

ng --version

angular-cli: 1.0.0-beta.23
node: 6.9.2
os: win32 x64

npm ls --depth=0

+-- UNMET PEER DEPENDENCY @angular/common@2.3.1
+-- @angular/compiler@2.3.1
+-- @angular/compiler-cli@2.3.1
+-- UNMET PEER DEPENDENCY @angular/core@2.3.1
+-- @angular/forms@2.3.1
+-- @angular/http@2.3.1
+-- @angular/material@2.0.0-alpha.11-3
+-- UNMET PEER DEPENDENCY @angular/platform-browser@2.3.1
+-- @angular/platform-browser-dynamic@2.3.1
+-- @angular/router@3.2.3
+-- @types/hammerjs@2.0.33
+-- @types/jasmine@2.5.38
+-- @types/node@6.0.52
+-- angular-cli@1.0.0-beta.23
+-- angularfire2@2.0.0-beta.6
+-- codelyzer@2.0.0-beta.3
+-- core-js@2.4.1
+-- firebase@3.6.4
+-- font-awesome@4.7.0
+-- hammerjs@2.0.8
+-- jasmine-core@2.5.2
+-- jasmine-spec-reporter@2.5.0
+-- karma@1.2.0
+-- karma-chrome-launcher@2.0.0
+-- karma-cli@1.0.1
+-- karma-jasmine@1.1.0
+-- karma-remap-istanbul@0.2.2
+-- protractor@4.0.13
+-- UNMET PEER DEPENDENCY rxjs@5.0.0-rc.4
+-- ts-helpers@1.1.2
+-- ts-node@1.2.1
+-- UNMET PEER DEPENDENCY tslint@4.1.0
+-- typescript@2.0.10
`-- zone.js@0.7.2

npm ERR! peer dep missing: @angular/common@2.2.3, required by @angular/router@3.2.3
npm ERR! peer dep missing: @angular/core@2.2.3, required by @angular/router@3.2.3
npm ERR! peer dep missing: @angular/platform-browser@2.2.3, required by @angular/router@3.2.3
npm ERR! peer dep missing: rxjs@5.0.0-beta.12, required by @angular/router@3.2.3
npm ERR! peer dep missing: rxjs@5.0.0-beta.12, required by angularfire2@2.0.0-beta.6
npm ERR! peer dep missing: tslint@~4.0.0, required by codelyzer@2.0.0-beta.3
npm ERR! peer dep missing: @angular/compiler-cli@2.2.3, required by @ngtools/webpack@1.1.9
npm ERR! peer dep missing: @angular/core@2.2.3, required by @ngtools/webpack@1.1.9
npm ERR! peer dep missing: tslint@^3.0.0, required by tslint-loader@2.1.5

ng serve

ngCompiler.ReflectorHost is not a constructor
TypeError: ngCompiler.ReflectorHost is not a constructor
     at AotPlugin._setupOptions (.\node_modules\@ngtools\webpack\src\plugin.js:136:31)
     at new AotPlugin (.\node_modules\@ngtools\webpack\src\plugin.js:37:14)
     at Object.exports.getWebpackAotConfigPartial (.\node_modules\angular-cli\models\webpack-build-typescript.js:44:13)
     at new NgCliWebpackConfig (.\node_modules\angular-cli\models\webpack-config.js:25:42)
     at Class.run (.\node_modules\angular-cli\tasks\serve-webpack.js:20:22)
     at .\node_modules\angular-cli\commands\serve.js:108:26
     at process._tickCallback (internal/process/next_tick.js:103:7)

@keyiis
Copy link

keyiis commented Dec 20, 2016

Has progress?i has same issuse,i used webpack(2.1.0-beta.25) @angular(2.2.3) @ngtools/webpack(1.1.9)

@soccio
Copy link

soccio commented Dec 21, 2016

had the same problem with beta 24, try creating a new project , then copy your source folder to that new project. then modify config files as required. It worked for me.

@mgol
Copy link
Member

mgol commented Dec 22, 2016

I had the same issue; all that was required to fix it was to remove node_modules and run npm install.

If you're using yarn you need to remove both node_modules and yarn.lock and run yarn afterwards. I suspect a dependency of a dependency is fixed in a newer version and you just need to update it.

@maxime1992
Copy link
Contributor

@mgol Thanks a lot, the problem was with yarn. I removed the yarn.lock and it's now working !

@arunswaminathank
Copy link

getting same error with angular 2.4.1 . Any specific details on which version of angular AOT works ?

@mgol
Copy link
Member

mgol commented Jan 4, 2017

@arunswaminathank Have you tried removing node_modules (and yarn.lock if you use yarn) and reinstalling dependencies?

@arunswaminathank
Copy link

arunswaminathank commented Jan 4, 2017 via email

@ichent
Copy link

ichent commented Jan 6, 2017

This is unreal. I can't build my project about 2 weeks. Every combination of versions gives different errors.

@zackarychapple
Copy link
Contributor

I'm using AOT with beta.24 and the below versions.

  "dependencies": {
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "^3.4.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.24",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.0.2",
    "typescript": "~2.0.3"
  }

@alvipeo
Copy link

alvipeo commented Jan 6, 2017

Let me try that today too. I put my prj on hold because of these issues like 3 weeks ago. Let's hope it'll work...

@stanislavromanov
Copy link

Still does not work. This is ridiculous.

@bliitzkrieg
Copy link

Was there a fix for this? I am experience this as well :(

@alvipeo
Copy link

alvipeo commented Jan 31, 2017

That's fixed pretty long time ago. My suggestion is to create a new project with beta.26 (the current version as I write this).

@keyiis
Copy link

keyiis commented Jan 31, 2017

I update all package to last version,the issuse fixed.

@naujfract
Copy link

I use this package.json and fixed!
"dependencies": {
"@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",
"@ionic-native/core": "3.4.2",
"@ionic-native/splash-screen": "3.4.2",
"@ionic-native/status-bar": "3.4.2",
"@ionic/storage": "2.0.1",
"ionic-angular": "3.0.1",
"ionicons": "3.0.0",
"rxjs": "5.1.1",
"sw-toolbox": "3.4.0",
"zone.js": "^0.8.4",
"@ionic-native/background-mode": "^3.4.4",
"@ionic-native/geolocation": "^3.4.4",
"@types/google-maps": "^3.2.0",
"angularfire2": "^2.0.0-beta.7",
"firebase": "^3.6.9",
"geofire": "^4.1.2"
},
"devDependencies": {
"@ionic/app-scripts": "1.3.0",
"typescript": "~2.2.1"
}

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests