bleenco / ngx-uploader

Angular File Uploader
https://ngx-uploader.jankuri.me
MIT License
757 stars 349 forks source link

Module parse failed: Unexpected token #58

Closed karljv closed 8 years ago

karljv commented 8 years ago

Hello

I cannot get yout library to compile. How am I supposed to get around this?

ERROR in ./~/ng2-uploader/ng2-uploader.ts Module parse failed: /var/www/html/project/node_modules/ng2-uploader/ng2-uploader.ts Unexpected token (14:30) You may need an appropriate loader to handle this file type.

jkuri commented 8 years ago

Hi @karljv, library is already compiled. In your tsconfig.json you may want to exclude node_modules.

taguan commented 8 years ago

My build broke since last minor version (unexpected token)... I came back to last version as a quick fix

jkuri commented 8 years ago

It works for me. Can you be more specific about the error?

taguan commented 8 years ago

Unfortunately I was in a hurry to unblock the situation (because the application wasn't starting anymore), so I didn't take the time to look at what was really going wrong.

The error in the console was the following

localhost/:172 Error: SyntaxError: Unexpected token < Evaluating http://localhost:5555/traceur Error loading http://localhost:5555/traceur Error loading http://localhost:5555/node_modules/ng2-uploader/ng2-uploader.js as "ng2-uploader/ng2-uploader" from http://localhost:5555/app/main.js "Report this error at https://github.com/mgechev/angular2-seed/issues"

I am loading ng2-uploader through systemjs in a gulp build.

jkuri commented 8 years ago

Thanks for reporting, I did update dependencies to RC5 this morning and removed typings as it now use core-js. I will check what can cause the issue.

taguan commented 8 years ago

I am still working on RC1, maybe it could be a cause of this issue ? This was sneaky because I didn't update myself the dependencies and it suddenly broke (because of a ^ prefix in my package.json)

jkuri commented 8 years ago

I am not sure since this module is not using nothing that changed from RC1.

karljv commented 8 years ago

Hello jkuri

My tsconfig.js looks like this

{
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "sourceMap": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noEmitHelpers": true,
    "removeComments": true,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "vendor",
    "resources/assets/typescript/vendor.ts",
    "resources/assets/typescript/typings/main",
    "resources/assets/typescript/typings/main.d.ts"
  ]
}

Every time I load ng2-uploader into my component like below, I get the same Module parse error.

import {UPLOAD_DIRECTIVES} from 'ng2-uploader/ng2-uploader';

@Component ({
    selector: 'add-user-modal',
    templateUrl: '/templates/Modals.add-user-modal',
    providers: [],
    directives: [
        closeComponent,
        addComponent,
        FORM_DIRECTIVES,
        UPLOAD_DIRECTIVES
    ]
})

Any help would be appreciated, because I seemingly cannot solve this issue alone

karljv commented 8 years ago

The error as a whole is as follows

ERROR in ./~/ng2-uploader/ng2-uploader.ts
Module parse failed: /var/www/html/ng2project/node_modules/ng2-uploader/ng2-uploader.ts Unexpected token (14:30)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (14:30)
    at Parser.pp$4.raise (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp$1.parseVar (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:1036:16)
    at Parser.pp$1.parseVarStatement (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:917:10)
    at Parser.pp$1.parseStatement (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:706:19)
    at Parser.pp$1.parseExport (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:1181:31)
    at Parser.pp$1.parseStatement (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:719:71)
    at Parser.pp$1.parseTopLevel (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:638:25)
    at Parser.parse (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:516:17)
    at Object.parse (/var/www/html/ng2project/node_modules/webpack/node_modules/acorn/dist/acorn.js:3098:39)
 @ ./resources/assets/typescript/Components/Main/Users/AddUserModal.ts 10:21-57
karljv commented 8 years ago

I'm still pondering around this issue, are there any solutions? Am I importing something wrong? I noticed that you mentioned that this is a precompiled library, but I still don't get why my textbook example import of your directive does not work, because I have excluded node_modules in my tsconfig.js.

Has this something to do with the fact that I'm using gulp to build my project?

jkuri commented 8 years ago

Hi @karljv, can you please try to use one version before latest?

karljv commented 8 years ago

I tried 0.5.10, but I got the same error. I'm probably trying to compile it wrong somehow.

karljv commented 8 years ago

Stopped trying, using another uploading directive