I fail to import the JL module from JSNLog in my TypeScript project. I installed my dependencies using JSPM:
jspm install npm:jsnlog
The documentation gives an example for node:
var JL = require('jsnlog').JL;
I tried to make it available in my project (for the browser) but I cannot make it work:
import JL from 'jsnlog' // TypeError: jsnlog_1.default.createConsoleAppender is not a function
import {JL} from 'jsnlog' // TypeError: Cannot read property 'createConsoleAppender' of undefined
const JL = require('jsnlog').JL // Error: require is not defined
import JL = require('jsnlog').JL // TypeError: JL.createConsoleAppender is not a function
Any wizard out there who can point me into the right direction?
// tsconfig.json
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false,
"module": "system",
"moduleResolution": "node",
"target": "es5"
}
According to the JNSLog author :
jsnlog.js is actually written in TypeScript:
https://github.com/mperdeck/jsnlog.js/blob/master/jsnlog.ts I used the TypeScript compiler to compile jsnlog.ts to jsnlog.js (which is pure > JavaScript).
Since your project is already typescript based I would import using the jsnlog.d.ts file (you might need to create this yourself).
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.