2017-07-17 168 views
0

我遇到一些安裝和使用jsnlog的問題,如the docs所述。當我嘗試導入或使用庫時,我總是收到錯誤。jsnlog在安裝時產生錯誤

我試圖導入庫,如文檔:

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. 

軟件版本 我包括node/npm/angular版本,因爲我感覺這個問題可能在這裏。我沒有嘗試這樣做比上最近其他節點的其他版本,但是這是一個相當大的項目,所以我不能輕易不會破壞應用程序

  • 角升級NPM或節點2.1.1
  • NPM 4.6.1
  • 節點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

的問題是,你在你的WebPack配置使用ts-loader,出於某種原因ts-loader不編譯jsnlog正確用awesome-typescript-loader更換ts-loader將解決問題。