用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.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
,但我收到了另一个错误:
An export assignment cannot be used in a module with other exported elements.
我也尝试将jasmine从devDependencies迁移到依赖项,它没有工作..
还尝试将compilerOptions.module
更改为无,无论是否......
并在浏览器中(业力):
应用-routing.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 { }
tsconfig.json :
{
"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