我想在我的 ionic 应用程序中使用 logentries.com 设置远程日志记录。
这是我的摘录package.json
:
"dependencies": {
"bunyan": "^1.8.5",
"bunyan-logentries": "^1.2.0",
},
"devDependencies": {
"@types/bunyan": "0.0.35",
"@types/bunyan-logentries": "0.1.30",
"typescript": "2.0.9"
},
代码
import {createStream} from "bunyan-logentries";
import * as Logger from "bunyan";
// ...
constructor() {
let token = 'xxxxxxxxxxxxxxxxx';
let log = Logger.createLogger({
name: '',
streams: [{
level: 'info',
stream: createStream({token: token}),
type: 'raw'
}]
});
log.info("Created log");
}
问题
我的 IDE 没有警告我任何错误。但是,一旦我运行该应用程序,我就会收到以下错误:
存在不是一个函数。(在 'exists(pkgPath)' 中,'exists' 是未定义的)
findPackage@http://localhost:8101/build/main.js:131257:18
register@http://localhost:8101/build/main.js:131332:31
http://localhost:8101/build/main.js:112585:50
http://localhost:8101/build/main.js:113391:34
__webpack_require__@http://localhost:8101/build/main.js:20:34
http://localhost:8101/build/main.js:129423:37
__webpack_require__@http://localhost:8101/build/main.js:20:34
http://localhost:8101/build/main.js:29972:95
__webpack_require__@http://localhost:8101/build/main.js:20:34
http://localhost:8101/build/main.js:80592:90
__webpack_require__@http://localhost:8101/build/main.js:20:34
http://localhost:8101/build/main.js:59390:96
__webpack_require__@http://localhost:8101/build/main.js:20:34
http://localhost:8101/build/main.js:59495:94
__webpack_require__@http://localhost:8101/build/main.js:20:34
http://localhost:8101/build/main.js:128048:94
__webpack_require__@http://localhost:8101/build/main.js:20:34
http://localhost:8101/build/main.js:116775:92
__webpack_require__@http://localhost:8101/build/main.js:20:34
http://localhost:8101/build/main.js:149625:89
__webpack_require__@http://localhost:8101/build/main.js:20:34
http://localhost:8101/build/main.js:66:37
global code@http://localhost:8101/build/main.js:67:12
我认为问题的核心是@types
与实际的节点模块不匹配,但目前尚不清楚应该如何解决这个问题。