Skip to content

Unexpected token export in ng run [project-name]:app-shell #15182

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
vugar005 opened this issue Jul 28, 2019 · 9 comments
Closed

Unexpected token export in ng run [project-name]:app-shell #15182

vugar005 opened this issue Jul 28, 2019 · 9 comments

Comments

@vugar005
Copy link

vugar005 commented Jul 28, 2019

ng run [project-name]: app-shell

Command (mark with an x)

- [x] generate

- [x] run

Description

This is not duplicate of #8848 .

When I run ng run [project-name]:app-shell
I get Unexpected token export error
Cli even does noes not inform in which file is the problem. So have no clue where to debug.
Tried --verbose but is not supported with this command.
I get no erorrs with ng-build --prod and ng run project-name:build .
Configured app shell with steps;

  1. ng generate universal --client-project=project-name
  2. ng generate app-shell --name=my-shell --universal-project=ngu-app-shell --route=app-shell-path --client-project=project-name

ng run [project-name]: app-shell builds and exports two builds in dist (dist/project-name and dist/project-name-server) but I do not see app-shell in dist/project-name/index.html

Thanks in advance

🔬 Minimal Reproduction

https://github.com/vugar005/app-shell-unexpected-token

🔥 Exception or Error

Unexpected token export without additional details.

🌍 Your Environment

@angular-devkit/architect 0.801.2
@angular-devkit/build-angular 0.801.2
@angular-devkit/build-optimizer 0.801.2
@angular-devkit/build-webpack 0.801.2
@angular-devkit/core 8.1.2
@angular-devkit/schematics 8.1.2
@angular/cdk 8.1.1
@angular/cli 8.1.2
@angular/material 8.1.1
@angular/material-moment-adapter 8.1.1
@ngtools/webpack 8.1.2
@schematics/angular 8.1.2
@schematics/update 0.801.2
rxjs 6.4.0
typescript 3.4.5
webpack 4.35.2

Also tried with
"@angular/cli": "~8.2.0-rc.0.",
"@angular/compiler-cli": "~8.2.0-next.1",
but same problem.

@vugar005 vugar005 changed the title Unexpected token in ng run [project-name]:app-shell Unexpected token export in ng run [project-name]:app-shell Jul 28, 2019
@alan-agius4 alan-agius4 added area: @angular-devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken labels Jul 29, 2019
@ngbot ngbot bot modified the milestone: needsTriage Jul 29, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jul 29, 2019
@alan-agius4
Copy link
Collaborator

Hi, the problem seems to be that some of your dependencies don't have a UMD bundles.

Example: countup.js

This is related to the following issue: #13181

That being said, we should display the module that is causing the problem so that users can track and action the issue quicker.

@vugar005
Copy link
Author

vugar005 commented Jul 29, 2019

@alan-agius4 Thank u for quick response. But why ng run plus-minus:server:production and ng run plus-minus:build:production does not produce that problem?

@alan-agius4
Copy link
Collaborator

The issue is that code is executed when running ng run [project-name]:app-shell that particular code is not compatible to be executed on Node to generate the Application shell.

  • ng run plus-minus:build:production works because the dependencies gets bundled and eventually the export syntax is removed.
  • ng run plus-minus:server:production doesn't fail because the code doesn't get executed but only built, However it will eventually fail when you try to execute it on the server.

@vugar005
Copy link
Author

vugar005 commented Jul 29, 2019

@alan-agius4 Thank u. The problem was with countup.js-angular2 plugin. Removed and problem was solved. But I think it is very useful that CLI notify which package causes this problem. Thanks in advance.

@Enngage
Copy link

Enngage commented Aug 9, 2019

Just had this issue as well. It would really be useful to get some stacktrace of the error, which I figured I can get by going to the dist folder where the main.js server file is generated and simply run node main, but this is not really obvious and many people can get frustrated.

@DanielYKPan
Copy link

We are trying to implement the app-shell in our product, and when we tried to build the app, it generated the same error Unexpected token export without extra information. Unfortunately, unlike the app in this issue, We have tons of dependencies and we don't know which ones causing the issue. It would be good to provide extra information and let the user know what causing the issue

@phetw
Copy link

phetw commented Oct 22, 2019

@DanielYKPan Try running node main.js file in serverdist. It will show the exact library that causes the error.

@alan-agius4
Copy link
Collaborator

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

@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 Jan 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants