jsnlog在安装时产生错误

时间:2017-07-17 23:16:54

标签: angular npm npm-install jsnlog

我在安装和使用jsnlog时遇到了一些问题,如the docs所述。当我尝试导入或使用该库时,我不断收到错误。

我尝试按照文档中导入库:

import { JL } from 'jsnlog'

我也尝试过这种方式(不要叫这种风格)

import 'jsnlog';

我运行npm run serve时在控制台中遇到的错误是:

ERROR in C:\Users\jeanpierreb\Documents\project\node_modules\jsnlog\Definitions\jl.d.ts
(279,10): error TS2304: Cannot find name 'r'.

ERROR in C:\Users\jeanpierreb\Documents\project\node_modules\jsnlog\Definitions\jl.d.ts
(279,12): error TS2304: Cannot find name 't'.

ERROR in C:\Users\jeanpierreb\Documents\project\node_modules\jsnlog\Definitions\jl.d.ts
(279,20): error TS2304: Cannot find name 'J'.

ERROR in C:\Users\jeanpierreb\Documents\project\node_modules\jsnlog\Definitions\jl.d.ts
(279,22): error TS2304: Cannot find name 'L'.

ERROR in ./app_ts/app.module.ts
(4,21): error TS2306: File 'C:/Users/jeanpierreb/Documents/project\node_modules/jsnlog/Definitions/jl.d.ts' is not a module.

软件版本 我包含节点/ npm / angular版本,因为我觉得问题可能就在这里。我没有在最新的节点之外的其他版本节点上尝试过这个,但这是一个相当大的项目,因此我不能在不破坏应用程序的情况下升级npm或节点

  • Angular 2.1.1
  • npm 4.6.1
  • node 6.10.3

为了完整性,这里是我的tsconfig和package.json

的package.json

  {
  "version": "1.0.0",
  "name": "myproject",
  "private": true,
  "scripts": {
    "postinstall": "typings install",
    "typings": "typings",
    "build": "webpack --progress",
    "build-prod": "webpack -p --progress --env.prod",
    "serve": "webpack --progress --colors --watch",
    "start": "lite-server"
  },
  "dependencies": {
    "@angular/common": "2.1.1",
    "@angular/compiler": "2.1.1",
    "@angular/core": "2.1.1",
    "@angular/forms": "2.1.1",
    "@angular/http": "2.1.1",
    "@angular/platform-browser": "2.1.1",
    "@angular/platform-browser-dynamic": "2.1.1",
    "@angular/router": "3.1.1",
    "@angular/upgrade": "2.1.1",
    "@ngrx/core": "^1.2.0",
    "@ngrx/store": "^2.2.2",
    "@types/handlebars": "4.0.32",
    "@types/jquery": "^2.0.34",
    "@types/signalr": "^2.0.2",
    "angular-in-memory-web-api": "0.3.0",
    "bootstrap": "3.3.7",
    "core-js": "2.4.1",
    "devextreme": "16.2.3",
    "devextreme-angular": "16.2.3-rc.3",
    "es6-shim": "0.35.3",
    "font-awesome": "4.7.0",
    "jquery": "3.1.1",
    "jsnlog": "^2.24.0",
    "json-stringify-safe": "^5.0.1",
    "jszip": "3.1.3",
    "lite-server": "2.2.2",
    "lodash": "4.17.4",
    "moment": "2.17.1",
    "ng2-ckeditor": "1.1.6",
    "ng2-vis": "0.0.5",
    "node-sass": "4.5.0",
    "null-loader": "^0.1.1",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.2.0",
    "sass-loader": "6.0.2",
    "scss-compile": "0.1.7",
    "signalr": "2.2.1",
    "style-loader": "0.13.2",
    "ts-loader": "2.0.1",
    "uglify-js": "2.8.13",
    "vis": "4.18.1",
    "zone.js": "0.7.7"
  },
  "devDependencies": {
    "angular2-router-loader": "^0.3.5",
    "assets-webpack-plugin": "^3.5.1",
    "compression-webpack-plugin": "0.3.2",
    "css-loader": "0.26.2",
    "lite-server": "2.2.2",
    "source-map-loader": "0.1.6",
    "style-loader": "0.13.2",
    "ts-loader": "2.0.1",
    "typescript": "2.2.1",
    "typings": "2.0.0",
    "uglifyjs-webpack-plugin": "0.3.0",
    "webpack": "2.2.1",
    "webpack-dev-server": "2.4.1",
    "webpack-merge": "4.1.0"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "outDir": "wwwroot/app",
    "rootDir": "app"


  },
  "compileOnSave": true,
  "exclude": [
    "wwwroot/node_modules",    
    "typings/index.d.ts",
    "typings/globals/index.d.ts",
    "typings/globals/jquery/index.d.ts",
    "node_modules"
  ]
}

1 个答案:

答案 0 :(得分:1)

问题是您在webpack配置中使用private void button3_Click_1(object sender, EventArgs e) { ListView listView1 = new ListView(); string splitter = ","; export2File(listview1, splitter); } ,由于某种原因,ts-loader无法正确编译ts-loader,只需将jsnlog替换为{{} 1}}将解决问题。