如何在webpack

时间:2016-11-30 09:39:36

标签: typescript webpack visual-studio-code aurelia

我想在我的Typescript Aurelia应用程序中使用下划线。 我创建了一个打字稿文件,我把它放在:

import * as _ from 'underscore'

但是VS Code说:

  

[ts]无法找到模块'下划线'

我把它放到webpack.config中:

plugins:[
    new webpack.ProvidePlugin({
      underscore:'underscore'
    })  
]

我也使用以下方法安装了下划线:

npm install --save underscore

我还需要做些什么才能让它发挥作用?

1 个答案:

答案 0 :(得分:4)

由于您使用的是TypeScript,因此还必须为下划线安装*.d.ts typing文件。尝试运行:

npm install --save @types/underscore

这让TS了解下划线模块及其接口。

Here's some more information about typings management with Typescript