我有一个使用node / npm,webpack和awesome-typescript-loader和Reactjs的项目。当我在热加载(webpack-dev-server)的开发人员模式下运行代码时,代码会编译,但不会重新编译。当我在生产环境中运行项目时(webpack && node server.js),所有编译都可以正常进行。
以下是错误消息:
TypeError:无法读取未定义的属性“ _tsInstances” 在resolveInstance(/Users/user/Documents/GitHub/project/node_modules/awesome-typescript-loader/src/instance.ts:73:20)
...
npm错误!代码ELIFECYCLE npm ERR! errno 1 npm ERR! project@0.0.0 dev:`webpack-dev-server,退出状态1
对此的任何帮助将不胜感激,如果您想查看更多错误消息或日志,请告诉我。
webpack.config.js
const path = require('path');
module.exports = {
entry: "./src/index.tsx",
output: {
filename: "js/bundle.js",
path: __dirname + "/dist"
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"]
},
devServer: {
contentBase: path.join(__dirname, "dist"),
proxy: {
"/api": "http://localhost:3000"
}
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ test: /\.(jpe?g|gif|png|svg)$/, loader: "file-loader?name=./images/[name].[ext]" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
externals: {
"react": "React",
"react-dom": "ReactDOM"
}
};
tsconfig.json
"compilerOptions": {
"outDir": "./dist/js/",
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es2015",
"jsx": "react",
"experimentalDecorators": true,
"allowJs": true,
"types": [
"googlemaps",
"geojson",
"prop-types",
"react",
"react-dom"
]
},
"include": [
"./src/**/*"
]