io17 icon indicating copy to clipboard operation
io17 copied to clipboard

Unexpected token import

Open BorntraegerMarc opened this issue 8 years ago • 8 comments

I get this error:

> [email protected] ngu-sw-manifest D:\projects\komed-health-web
> node ./node_modules/ng-pwa-tools/bin/ngu-sw-manifest.js --module src/app/app.module.ts --out dist/ngsw-manifest.json

D:\projects\komed-health-web\src\app\app.module.ts:2
import { NgModule, CUSTOM_ELEMENTS_SCHEMA  } from '@angular/core';
^^^^^^
SyntaxError: Unexpected token import

When running node ./node_modules/ng-pwa-tools/bin/ngu-sw-manifest.js --module src/app/app.module.ts --out dist/ngsw-manifest.json

BorntraegerMarc avatar May 23 '17 11:05 BorntraegerMarc

Same here.

GuskiS avatar May 23 '17 11:05 GuskiS

Also I'm getting weird errors if this is my app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA  } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { PolymerModule } from '@codebakery/origami';
import { IronElementsModule, PaperElementsModule, AppElementsModule } from '@codebakery/origami/lib/collections';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    PolymerModule,
    IronElementsModule,
    PaperElementsModule,
    AppElementsModule
  ],
  providers: [],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  bootstrap: [AppComponent]
})
export class AppModule { }

Somebody knows why? This also happens on OSX...

BorntraegerMarc avatar May 23 '17 12:05 BorntraegerMarc

Here is my error stack trace:

ngu-app-shell --module src/app/app.module.ts
/Users/julienrenaux/Sites/ionic-twitter-pwa/src/app/app.module.ts:7
import { BrowserModule } from '@angular/platform-browser';
^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Module.m._compile (/Users/julienrenaux/Sites/ionic-twitter-pwa/node_modules/ts-node/src/index.ts:382:23)
    at Module._extensions..js (module.js:580:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/Users/julienrenaux/Sites/ionic-twitter-pwa/node_modules/ts-node/src/index.ts:385:12)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

shprink avatar Jun 08 '17 13:06 shprink

I am also getting the same error, using the following gist for the time being https://gist.github.com/gund/651bdbe7339a40b94fab3c0e6a3b3fb2

rmchndrng avatar Jun 25 '17 14:06 rmchndrng

Same here on error as above examples..

chakrachi avatar Jul 06 '17 10:07 chakrachi

i had the same issue, and solved it, deleting all .js and .js.map compiled, and then, i run build --prod again (without aot). After that, i run the command ngu-sw-manifest. if the next issue is "Error: ENOENT: no such file or directory", check if the all component had moduleId

Pillin avatar Aug 10 '17 20:08 Pillin

Same here...

DominicBoettger avatar Aug 25 '17 09:08 DominicBoettger

Same issue here... When I try to apply app-shell as such

ngu-app-shell.js --module src/app/app.module.ts --out dist/index.html

(function (exports, require, module, __filename, __dirname) { import { Inject, Injectable, NgModule } from '@angular/core';
^
SyntaxError: Unexpected token import
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/Users/sandbox/src/app/app.module.ts:6:1)

app.module.ts:6:1 where it is referencing my private npm module

playground avatar Sep 12 '17 19:09 playground