angular - Ionic 2/Typescript 构建失败 : Unexpected character '@'

标签 angular typescript ionic2 tsconfig

我在使用项目中 ionic 2 项目之外的自己的 typescript 文件时遇到问题。我有一个我想使用的身份验证模块,但它无法正常工作。我不确定这是 typescript 设置问题还是 ionic 问题。

app.module.ts

import { NgModule } from '@angular/core';
import {IonicApp, IonicModule} from 'ionic-angular';
import { MyApp } from './app.component';
import { LoginComponent } from './login/login.component';
import {AuthModule} from "../../../web/src/shared/services/auth/auth.module";

@NgModule({
    declarations: [
        MyApp,
        LoginComponent
    ],
    imports: [
        IonicModule.forRoot(MyApp),
        AuthModule
    ],
    bootstrap: [IonicApp],
    entryComponents: [
        MyApp,
        LoginComponent
    ],
    providers: [
    ]
})
export class AppModule {}

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["dom", "es2015"]
  },
  "exclude": ["node_modules"],
  "compileOnSave": false,
  "atom": { "rewriteTsconfig": false }
}

auth.module.ts

import {NgModule} from "@angular/core";
import {HttpModule} from "@angular/http";
import {IdentityService} from "./identity.service";
import {IdentityEventService} from "./identity-event.service";
@NgModule({
    imports: [HttpModule],
    providers: [
        IdentityService,
        IdentityEventService
    ]
})
export class AuthModule {
}

我收到以下错误:

[14:34:24] 捆绑失败:..../web/src/shared/services/auth/auth.module.ts 中的意外字符“@”(5:0)

所以它看起来好像正在找到包,但在 NgModule 声明中窒息。如果我删除对 auth.module 的引用,它将起作用。我已经将 auth 模块需要的所有包添加到我的 ionic 项目的 package.json 文件中,因此引用应该不是问题。

如果需要更多相关信息来调试它,请告诉我。

最佳答案

我在制作我的第一个 ionic2 应用程序时遇到了同样的问题。我发现当我将我的提供程序(标记为@injectable)导入到 app.module.ts 时,它们被导入为“../authservice.ts”等而不是“../authservice”。检查是否是这种情况并删除 .ts .. im on ionic 2.1.0

关于angular - Ionic 2/Typescript 构建失败 : Unexpected character '@' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40163312/

相关文章:

css - 在输入元素 Ionic 的中间垂直对齐 float 标签

javascript - this.form.get 不是一个函数吗?

javascript - 找不到主要导出来加载 Angular 2

javascript - 类型 'Object' 不可分配给 Angular 4.x 应用程序中的类型 'any[]'

typescript - 源映射(用于浏览器扩展)在 Chrome 75、Edge 77 中对我不起作用

javascript - Ionic 2从ts文件引用html文件中的值?

javascript - 无法读取 PDF 组件中未定义的属性 'forEach'

typescript - OO 到函数式——从日常问题中学习

javascript - 无法对 type=number 的输入字段应用限制

javascript - ionic 2 : Get the header of a response in http request