Angular-cli: Symbol without members expected error after 2.4.7 -> 4.0.0-beta.8

Created on 19 Feb 2017  路  21Comments  路  Source: angular/angular-cli

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
After moving from 2.4.7 to 4.0.0-beta.8 I'm getting the following error when executing ng build -prod. Just ng build (without -prod) works fine.

ERROR in Illegal state: symbol without members expected, but got {"filePath":"C:/Projects/myproj/node_modules/@angular/router/index.d.ts","name":"__router_private__","members":["ROUTER_PROVIDERS"]}.

Expected behavior

ng build -prod should work as ng build

Please tell us about your environment:
Windows 10, @angular/cli 1.0.0-beta.32.3

  • Angular version: 4.0.0-beta.8
  • Node (for AoT issues): node --version = 7.5.0

Most helpful comment

I found the problem. For some reason the production build is compiling the spec.ts files although the documentation says it is exclude "*/.spec.ts" files by default. I added this to src/tsconfig.json:
"exclude": [ "**/*.spec.ts" ]

Now it compiles successfully (ng build -prod) with the unit test re-enabled.

All 21 comments

@ctrl-brk ,how you did "moving from 2.4.7 to 4.0.0-beta.8"?

just upgrade the "angular" module in the package.json?

Yes. Is there anything else needs to be done?

i'm so sorry, indeed, i have no idea;
maybe you can try "ng new your_project_name --ng4" with the --ng4 flag; or wait for the angular4 release on Mar.... good luck.

@ctrl-brk can you post the results of ng --version?

Also seeing the same upgrading from beta 7 to beta 8. Only occurs on the AOT build:

ERROR in Illegal state: symbol without members expected, but got {"filePath":"/Users/jinder/git/kangaroom-web/node_modules/@angular/router/index.d.ts","name":"__router_private__","
members":["ROUTER_PROVIDERS"]}.

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/jinder/git/kangaroom-web/src'
 @ ./src/main.ts 5:0-74
 @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

Version details:

@angular/cli: 1.0.0-beta.32.3 [1.0.0-beta.25.5]
node: 7.5.0
os: darwin x64
@angular/common: 4.0.0-beta.8
@angular/compiler: 4.0.0-beta.8
@angular/core: 4.0.0-beta.8
@angular/forms: 4.0.0-beta.8
@angular/http: 4.0.0-beta.8
@angular/platform-browser: 4.0.0-beta.8
@angular/platform-browser-dynamic: 4.0.0-beta.8
@angular/router: 4.0.0-beta.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 4.0.0-beta.8

Same problem here.

My guess is that we need to fix the config files.

Best way will be to ng init an empty project and diff to see which changes need to be done.

Edit: could not find any change necessary compared to a 'ng new test --ng4'

My current quickfix: downgrade to beta7

@deebloo
@angular/cli: 1.0.0-beta.32.3
node: 7.5.0
os: win32 x64
@angular/common: 4.0.0-beta.8
@angular/compiler: 4.0.0-beta.8
@angular/core: 4.0.0-beta.8
@angular/http: 4.0.0-beta.8
@angular/platform-browser: 4.0.0-beta.8
@angular/platform-browser-dynamic: 4.0.0-beta.8
@angular/forms: 4.0.0-beta.8
@angular/router: 4.0.0-beta.8
@angular/compiler-cli: 4.0.0-beta.8
@angular/platform-server: 4.0.0-beta.8
@angular/language-service: 4.0.0-beta.8
@angular/cli: 1.0.0-beta.32.3

I am having the same problem with an existing app. I started a new project in an empty folder ng new foo --ng4 and ng build -prod built successfully. I then started copying pieces from my application and it would still build fine - until - I got to my page header component. The the build failed with the "symbols without members expected" error.

  • I removed the header component (deleted the files, removed it from app.module.ts and app.component.html) and the build worked.
  • I added back the header html, scss, and ts file. If I delete the contents of the ts file - the build works.
  • I tried removing pieces of the ts file but I have been getting inconsistent results. Sometimes the build works if I remove the dependency injection parameters in the constructor - but other times the build doesn't work. The header takes two parameters (auth service and router).

I am still trying to nail down a consistently reproducible case.

The problem I have seems to be with the test for my header component (header.component.spec.ts). It is using the RouterTestingModule. I commented out the entire test file and now I can build production successfully.

I am not sure why a testing file would affect the production build but now I am past this problem. Later I will revisit the test and try to fix it.

I found the problem. For some reason the production build is compiling the spec.ts files although the documentation says it is exclude "*/.spec.ts" files by default. I added this to src/tsconfig.json:
"exclude": [ "**/*.spec.ts" ]

Now it compiles successfully (ng build -prod) with the unit test re-enabled.

same problem here by upgrading from beta7 to beta8.
ng build is working but -prod is not working.
same error, same package version as to.
adding exclude to tson.config doesn't worked for me but deleting all spec files did.

Make sure you add the exclude in the correct place in src/tsconfig.json (I mention this because I did it wrong the first time).

{
  "compilerOptions": {
    "baseUrl": "",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016",
      "dom"
    ],
    "mapRoot": "./",
    "module": "es2015",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ]
  },
  "exclude": [
    "**/*.spec.ts"
  ]
}

I think the changes made 1.0.0-rc.0 (which have the exclude in src/tsconfig.app.json) mean this issue could be closed.

getting similar error, but with actual app code:

Illegal state: symbol without members expected, but got {"filePath":"B:/Source/myapp/web/src/app/store/index.ts","name":"effects","members":["HomeEffects"]}.

the file referenced in the error looks like this:

import * as reducers from './reducers';
import * as actions from './actions';
import * as effects from './effects';

export { reducers, actions, effects };

Is this not an AOT compatible code?

Update
The moment I remove imports from this file and instead import things directly from app/store/effects, app/store/actions, and app/store/reducers, it starts working. So indeed it seems that AOT does not handle re-export file I used before, which is unfortunate for convenience reasons.

Is this a bug or expected behavior?

Fixed by https://github.com/angular/angular-cli/pull/4924

@DmitryEfimenko your issue is not the same as this one. Please open up a new issue and fill in the template.

@DmitryEfimenko Did you report your problem with re-export?
I think I have the same problem.

@MaklaCof I didn't open a new issue. Please feel free to do it. Also please link it here. I'd like to subscribe to it.

@DmitryEfimenko Posted

i had the same problem, fixed it by running a different build command line:

instead of ng build --prod use ng build --env=prod

For anyone else reading this, please be wary of the suggestion of reverting to --env=prod. Doing so changes the behaviour, as per the documentation for ng build, by effectively disabling ahead-of-time compilation (--aot=false).

It will "work" in that you'll get a build, but that build does not contain AoT-compiled templates.

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._

Was this page helpful?
0 / 5 - 0 ratings