I am having some issues installing and using jsnlog as described on the docs . I keep getting errors when I try to import or use the library.
I tried to import the library as in the docs:
import { JL } from 'jsnlog'
I also tried including it this way (don't what this style is called)
import 'jsnlog';
The errors I get in the console when I run npm run serve
are:
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.
Software Versions I'm including the node/npm/angular versions because I have a feeling the issue may be here. I haven't tried this on other versions of node other than the most recent, but this is a rather large project so I can't readily upgrade npm or node without breaking the app
For completeness here is my tsconfig and 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"
]
}
问题是您在Webpack配置中使用了ts-loader
,由于某种原因, ts-loader
无法通过使用awesome-typescript-loader
jsnlog
ts-loader
替换ts-loader
jsnlog
正确编译jsnlog
会解决此问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.