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

@reginaldocmrg WOW that worked!

sclausen avatar Dec 12 '16 14:12 sclausen

How do you actually rollback, though? I performed a global install of [email protected], after global removing 22, and still have .beta22! I feel liked I'm negotiating with a cartoon.

Adrriver avatar Dec 12 '16 15:12 Adrriver

I installed [email protected] locally.

reginaldocmrg avatar Dec 12 '16 15:12 reginaldocmrg

@Adrriver it worked well for me

sudo npm uninstall -g angular-cli
sudo npm install -g [email protected]

sclausen avatar Dec 12 '16 16:12 sclausen

@Adrriver solution works for me also...

ritox842 avatar Dec 13 '16 07:12 ritox842

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

mahindar5 avatar Dec 13 '16 09:12 mahindar5

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

stanislavromanov avatar Dec 13 '16 09:12 stanislavromanov

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

mahindar5 avatar Dec 13 '16 09:12 mahindar5

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

daviddsingleton avatar Dec 13 '16 16:12 daviddsingleton

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

jessezhang91 avatar Dec 13 '16 18:12 jessezhang91

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/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- UNMET PEER DEPENDENCY @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- UNMET PEER DEPENDENCY @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- @types/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- UNMET PEER DEPENDENCY [email protected]
+-- [email protected]
+-- [email protected]
+-- UNMET PEER DEPENDENCY [email protected]
+-- [email protected]
`-- [email protected]

npm ERR! peer dep missing: @angular/[email protected], required by @angular/[email protected]
npm ERR! peer dep missing: @angular/[email protected], required by @angular/[email protected]
npm ERR! peer dep missing: @angular/[email protected], required by @angular/[email protected]
npm ERR! peer dep missing: [email protected], required by @angular/[email protected]
npm ERR! peer dep missing: [email protected], required by [email protected]
npm ERR! peer dep missing: tslint@~4.0.0, required by [email protected]
npm ERR! peer dep missing: @angular/[email protected], required by @ngtools/[email protected]
npm ERR! peer dep missing: @angular/[email protected], required by @ngtools/[email protected]
npm ERR! peer dep missing: tslint@^3.0.0, required by [email protected]

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)

alorle avatar Dec 16 '16 01:12 alorle

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

keyiis avatar Dec 20 '16 08:12 keyiis

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.

soccio avatar Dec 21 '16 11:12 soccio

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.

mgol avatar Dec 22 '16 16:12 mgol

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

maxime1992 avatar Dec 23 '16 10:12 maxime1992

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

arunswaminathank avatar Jan 04 '17 11:01 arunswaminathank

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

mgol avatar Jan 04 '17 11:01 mgol

Yes, I tried , still the same error

On 04-Jan-2017 5:04 PM, "Michał Gołębiowski" [email protected] wrote:

@arunswaminathank https://github.com/arunswaminathank Have you tried removing node_modules (and yarn.lock if you use yarn) and reinstalling dependencies?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/3241#issuecomment-270351603, or mute the thread https://github.com/notifications/unsubscribe-auth/ATftz-WUvXjQHyMBgMi-cPNyvpWl3NUtks5rO4OqgaJpZM4K6EUT .

arunswaminathank avatar Jan 04 '17 12:01 arunswaminathank

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

ichent avatar Jan 06 '17 13:01 ichent

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

zackarychapple avatar Jan 06 '17 13:01 zackarychapple