angular2后台管理系统

angular2-4对angular1的改变是颠覆性的,增加了npm, typescript,@等目前前端开发流行的元素,但坑多

github上开源项目:https://github.com/mrholek/CoreUI-Free-Bootstrap-Admin-Template/tree/master/Angular2_CLI_Full_Project
这是基于angular2的后台管理系统

执行npm start时webpack:compiled successfully,但运行时报错,如下:

EXCEPTION: Uncaught (in promise): Error: Cannot find module './dashboard/dashboard.module'.
Error: Cannot find module './dashboard/dashboard.module'.
    at ZoneAwareError (http://localhost:4200/polyfills.bundle.js:6361:33)
    at webpackAsyncContext (http://localhost:4200/main.bundle.js:35:25)
    at SystemJsNgModuleLoader.webpackJsonp.../../../../_@angular_core@2.4.9@@angular/core/src/linker/system_js_ng_module_factory_loader.js.SystemJsNgModuleLoader.loadAndCompile 

显然是路由ts文件中报错,但设置是对的。
将路由文件代码中./改为app/就可以,原因是angular-cli版本过低,解决方法调高angular-cli版本。

改了后,npm start,编译报错,如下:

Searching for devices...
iTunes is not available for this operating system. You will not be able to work with connected iOS devices.
Executing before-prepare hook from /home/dhrn/NativeApp/Supervisor/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.4.1
node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.
  Types of property 'lift' are incompatible.
    Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'.
      Type 'Observable<T>' is not assignable to type 'Observable<R>'.
        Type 'T' is not assignable to type 'R'.

原因是package.json中typescript与rxjs版本冲突,可以在tsconfig.json中增加:”noStrictGenericChecks”: true,如下:

{
  "compilerOptions": {
    "baseUrl": "",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "noStrictGenericChecks": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016",
      "dom"
    ],
    "mapRoot": "./",
    "module": "es2016",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ]
  }
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值