【发布时间】:2017-04-16 06:56:27
【问题描述】:
我正在尝试使用 Typescript 2、Webpack 和 Angular 1.5,但是在构建 Webpack 时一直抱怨它:
无法解析 C:\play\gt\src 中的模块“@types/angular”
我被难住了。一直在谷歌上搜索并搞砸,但无处可去。
我的 app.ts 看起来像:
import * as angular from "@types/angular";
let app = angular.module ("GT.module", []);
我的 tsconfig 看起来像:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"typeRoots" : [
"node_modules/@types"
]
},
"exclude": [
"node_modules",
"**/*.spec.ts"
],
"include" : [
"src/**/*"
]
}
...最后是 webpack 配置:
module.exports = {
entry: './src/app.ts',
output: {
filename: './dist/app.js'
},
devtool: "source-map",
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.js'],
modulesDirectories: ["node_modules"]
},
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader' }
]
}
}
【问题讨论】:
标签: angularjs typescript webpack