Skip to content

Symbol without members expected error after 2.4.7 -> 4.0.0-beta.8 #4821

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

Closed
ctrl-brk opened this issue Feb 19, 2017 · 21 comments
Closed

Symbol without members expected error after 2.4.7 -> 4.0.0-beta.8 #4821

ctrl-brk opened this issue Feb 19, 2017 · 21 comments

Comments

@ctrl-brk
Copy link

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
@guzuomuse
Copy link

@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?

@ctrl-brk
Copy link
Author

Yes. Is there anything else needs to be done?

@guzuomuse
Copy link

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.

@deebloo
Copy link
Contributor

deebloo commented Feb 20, 2017

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

@jinder
Copy link

jinder commented Feb 20, 2017

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

@Thommas
Copy link

Thommas commented Feb 21, 2017

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

@ctrl-brk
Copy link
Author

@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

@daddyman
Copy link

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.

@daddyman
Copy link

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.

@daddyman
Copy link

daddyman commented Feb 23, 2017

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.

@ghost
Copy link

ghost commented Feb 24, 2017

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.

@daddyman
Copy link

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

@daddyman
Copy link

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.

@DmitryEfimenko
Copy link

DmitryEfimenko commented Mar 6, 2017

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?

@filipesilva
Copy link
Contributor

Fixed by #4924

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

@MaklaCof
Copy link

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

@DmitryEfimenko
Copy link

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

@MaklaCof
Copy link

MaklaCof commented May 25, 2017

@DmitryEfimenko Posted

@EmanuelCarneiro
Copy link

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

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

@junglebarry
Copy link

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.

@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