2016-08-20 158 views

回答

0

首先,安裝 '分型':npm install typings --global

然後,在命令行(在你的項目的根),使用分型安裝」 .D。 TS溫斯頓文件':

typings install winston --source dt --save --global 

的分型文件將被加入到typings/global/winston文件夾中的項目。現在,添加以下到您的「app.js」文件的頂部:

/// <reference path="typings/globals/winston/index.d.ts"/> 

現在,您可以使用溫斯頓記錄是這樣的:

var winston = require('winston'); 

winston.level = 'debug'; 
winston.debug('Debug messages are written to the console with the default logger.'); 

我加入了「FS-etxra」 NPM包到項目,然後按照上述相同的方式添加類型。由此產生的項目可以在以下截圖中看到:

Visual Studio Screenshot