我试图去抓住用打字稿2的WebPack和角1.5,但建设时的WebPack不断抱怨它:说服的WebPack使用node_modules/@类型
无法解析模块“@类型/角'in C:\ play \ gt \ src
我很难过。一直在谷歌搜索和搞乱,但我无处可去。
我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' }
]
}
}
谢谢!这已经解决了它。 Typescript目标帖子似乎在不停地移动,很难找到最新的文章。 – jeffeld
是啊,我知道,JavaScript生态系统发展得非常快,尝试官方文档,它保持相当不错。例如,这个链接将使用typescript包装webpack:https://www.typescriptlang.org/docs/handbook/react-&-webpack.html –