如何使用LogEntries我有這個tsconfig.json
:對角2個應用程序(打字稿)
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "dist"
},
"exclude": [
"node_modules"
]
}
隨着dashboard.component.ts
:
import { Component, OnInit } from '@angular/core';
import Logger = require('le_node');
var log = new Logger({
token:'abcdef-1234-ghijklm-5678-nopqrstuvwxyz'
});
@Component({
selector: 'dashboard',
templateUrl: 'app/dashboard.component.html'
})
export class DashboardComponent implements OnInit {
constructor() { }
ngOnInit(): void {
log.log('Test LogEntries...');
}
}
和運行npm install le_node --save
安裝LogEntries。當試圖與npm start
運行應用程序,我收到此錯誤:
> [email protected] start /Users/user/Workspace/sample-app
> tsc && concurrently "tsc -w" "lite-server"
app/dashboard.component.ts(10,25): error TS2307: Cannot find module 'le_node'.
嗨@basarat,感謝您的幫助,但它不是爲我工作。我在_https://angular.io/docs/ts/latest/quickstart.html_中提到了啓動項目,並且在'npm install'時,它使用'global'構建了'typings'路徑(對於core-js,jasmine和節點類型定義)和'index.d.ts'。我試圖在'index.d.ts'和'globals.d.ts'上聲明** le_node **,但仍然得到'GET http:// localhost:3000/le_node 404(Not Found)'。如果你有其他的選擇,我也贊同。 – leomperes