Angular 错误:未定义导出-Nativescript
我尝试用jasmine测试应用程序,编译完成后,我收到以下消息:Angular 错误:未定义导出-Nativescript,angular,typescript,testing,jasmine,nativescript,Angular,Typescript,Testing,Jasmine,Nativescript,我尝试用jasmine测试应用程序,编译完成后,我收到以下消息: Chrome 67.0.3396 (Windows 10 0.0.0) ERROR { "message": "Uncaught ReferenceError: exports is not defined\nat app/app-routing.module.js:2:23\n\nReferenceError: exports is not defined\n at app/app-routing.module
Chrome 67.0.3396 (Windows 10 0.0.0) ERROR
{
"message": "Uncaught ReferenceError: exports is not defined\nat app/app-routing.module.js:2:23\n\nReferenceError: exports is not defined\n at app/app-routing.module.js:2:23",
"str": "Uncaught ReferenceError: exports is not defined\nat app/app-routing.module.js:2:23\n\nReferenceError: exports is not defined\n at app/app-routing.module.js:2:23"
}
我试图在文件顶部添加export=0
,但我遇到另一个错误:
导出分配不能与其他导出元素一起在模块中使用。
我还试图将jasmine从依赖项转移到依赖项,但没有成功
还尝试将编译器选项。模块更改为无,也不起作用。。。
并在浏览器中(karma):
应用程序路由.module.ts:
import { NgModule } from "@angular/core";
import { Routes } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { LoggedInLazyLoadGuard } from "./logged-in-lazy-load.guard";
const routes: Routes = [
{ path: "", redirectTo: "/home", pathMatch: "full" },
{ path: "login", loadChildren: "./login/login.module#LoginModule" },
{ path: "home", loadChildren: "./home/home.module#HomeModule", canLoad: [LoggedInLazyLoadGuard] }
];
@NgModule({
imports: [NativeScriptRouterModule.forRoot(routes)],
exports: [NativeScriptRouterModule]
})
export class AppRoutingModule { }
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"lib": [
"es6",
"dom",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"~/*": [
"app/*"
],
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
},
"exclude": [
"node_modules",
"platforms"
]
}
tsconfig.json:
import { NgModule } from "@angular/core";
import { Routes } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { LoggedInLazyLoadGuard } from "./logged-in-lazy-load.guard";
const routes: Routes = [
{ path: "", redirectTo: "/home", pathMatch: "full" },
{ path: "login", loadChildren: "./login/login.module#LoginModule" },
{ path: "home", loadChildren: "./home/home.module#HomeModule", canLoad: [LoggedInLazyLoadGuard] }
];
@NgModule({
imports: [NativeScriptRouterModule.forRoot(routes)],
exports: [NativeScriptRouterModule]
})
export class AppRoutingModule { }
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"lib": [
"es6",
"dom",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"~/*": [
"app/*"
],
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
},
"exclude": [
"node_modules",
"platforms"
]
}
版本
tns: 4.1.0
npm: 6.1.0
node: 8.11.2
您能从tsconfig.json文件中删除“”模块“:”commonjs“,
”并尝试吗???@Sanoj_V i已删除,但仍然存在相同的错误。。