Skip to content

SyntaxError: Unexpected token < at eval (<anonymous>) #1996

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
ghost opened this issue Jun 29, 2017 · 12 comments
Closed

SyntaxError: Unexpected token < at eval (<anonymous>) #1996

ghost opened this issue Jun 29, 2017 · 12 comments

Comments

@ghost
Copy link

ghost commented Jun 29, 2017

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 use [gitter](https://gitter.im/mgechev/angular2-seed) or [stackoverflow](https://stackoverflow.com/questions/tagged/angular2)

Current behavior


image

Expected behavior

Needs to compile and run without error

Minimal reproduction of the problem with instructions

It works with previous version but I get this error when I update my code with the latest version of angular-seed.

Please tell us about your environment:

OS: Windows X
IDE: None
Package manager: npm v.6.9.1

  • Angular Seed Version: aaaaf75
  • Node: node --version = v6.9.1
@mgechev
Copy link
Owner

mgechev commented Jun 29, 2017

That's incorrect import, not an issue in Angular seed.

@mgechev mgechev closed this as completed Jun 29, 2017
@ghost
Copy link
Author

ghost commented Jun 29, 2017

Is it the third party library you are talking about?

@mgechev
Copy link
Owner

mgechev commented Jun 29, 2017

@arun-awnics you can take a look at the network tab and see which file is not being loaded properly. What happens is:

  • You try to load a non-existing module with SystemJS.
  • The dev server returns index.html.
  • SystemJS tries to run index.html as JavaScript.
  • You can the error SyntaxError: Unexpected token < at eval.

@ghost
Copy link
Author

ghost commented Jun 29, 2017

I am doubting that's not the problem I am facing. I did what you said in the network tab. I see that I have included all the imports in project.config.ts.

I get this error while compiling:
src\client\app\system-config.ts(1,13): error TS2451: Cannot redeclare block-scoped variable 'System'.

What does that mean? Can you please tell me what it is? @mgechev
Thank you in advance.

@maxmarkus
Copy link

@arun-awnics With seed update some changes got introduced here.
I also had to disable/remove the first declare var System: SystemJSLoader.System; line inside src\client\app\system-config.ts, then it worked.

@ghost
Copy link
Author

ghost commented Jul 1, 2017

Hey @maxmarkus Even after removing or commenting the first line, I still get the same error.

@mathijshoogland
Copy link
Contributor

I'm having the same problem, did you find a solution @arun-awnics?

@ghost
Copy link
Author

ghost commented Jul 10, 2017

No @mathijshoogland I tried everything said above and it still doesn't work. Were you able to find the solution?

@hhubik
Copy link

hhubik commented Jul 14, 2017

Also running into this. Get the following error at run-time:
localhost/:57 SyntaxError: Unexpected token < at eval (<anonymous>) at evaluate (http://localhost:5555/node_modules/systemjs/dist/system.src.js?1499990207511:2821:16) at http://localhost:5555/node_modules/systemjs/dist/system.src.js?1499990207511:3620:21 at dynamicExecute (http://localhost:5555/node_modules/systemjs/dist/system.src.js?1499990207511:1144:26) at doEvaluate (http://localhost:5555/node_modules/systemjs/dist/system.src.js?1499990207511:1091:13) at ensureEvaluate (http://localhost:5555/node_modules/systemjs/dist/system.src.js?1499990207511:999:13) at http://localhost:5555/node_modules/systemjs/dist/system.src.js?1499990207511:1017:20 at Object.eval (http://localhost:5555/app/shared/shared.module.js:13:17) at eval (http://localhost:5555/app/shared/shared.module.js:52:4) at eval (http://localhost:5555/app/shared/shared.module.js:53:3) Not expecting this error? Report it to support

Started working again on my Angular 2 project after about 4 months. The project used to work fine at that time. Made no other changes, just updated to the latest Seed, which brought my project from Angular 4.0.0 to 4.2.3.

Don't see any errors (missing files) in the Network tab of Dev tools. The project compiles with no errors in Typescript 2.4.1. Tried removing and re-installing node_modules directory. No difference.

Any suggestion on how to debug this?

@skolli853780
Copy link

I am getting same error..arun, Did you fix this issue?

@hhubik
Copy link

hhubik commented Aug 23, 2017

@skolli853780 - in my case the problem was due to some third part libraries/packages not getting loaded. I managed to use the debugger (set a break point in code just before the error occurs, then turn on 'break on exception') to identify the library that could not be loaded. For each of the 'unloadable' libraries, I had to add the following code (using base64-js as example) to additionalPackages in my project.confiig.ts:

{
      name: 'base64-js',
      path: 'node_modules/base64-js/index.js',
      packageMeta: {
        defaultExtension: 'js'
      }
    }

@sparachi
Copy link

@hhubik your suggestion helped me to resolve the unexpected token issue. I had multiple packages breaking so fixed one by one added entries to project.config.ts file . Attaching screenshot if it might help others, please have breakpoint at the file and look for 'address' that indicates you the package.

seed issue unexpected token

below are 2 such packages

  {
    name: 'rxjs',
    path: 'node_modules/rxjs/bundles/Rx.js',
  },
  {
    name: 'moment',
    path: 'node_modules/moment',
    packageMeta: {
      main: 'moment.js',
      defaultExtension: 'js'
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants