Node.js 网页包未按预期传输我的.ts
我在应用程序的后端(nodejs)使用webpack,主要是将我的.ts传输到.js。但它不起作用。它处理需要控制器文件夹的app.ts,但webpack抱怨:Node.js 网页包未按预期传输我的.ts,node.js,webpack,visual-studio-code,Node.js,Webpack,Visual Studio Code,我在应用程序的后端(nodejs)使用webpack,主要是将我的.ts传输到.js。但它不起作用。它处理需要控制器文件夹的app.ts,但webpack抱怨: ERROR in ./app.ts Module not found: Error: Cannot resolve 'file' or 'directory' ./controllers in C:\Users\markn\Documents\source\ftct @ ./app.ts 3:18-42 我的webpack.confi
ERROR in ./app.ts
Module not found: Error: Cannot resolve 'file' or 'directory' ./controllers in C:\Users\markn\Documents\source\ftct
@ ./app.ts 3:18-42
我的webpack.config.js的摘录如下所示:
module.exports = [{
{
// back end
context: app,
entry: {
app: ['webpack/hot/dev-server', './app.ts']
},
target: 'node',
devtool: 'source-map',
output: {
path: app,
filename: 'app.js'
},
externals: nodeModules,
module: {
loaders: [
{ test: /\.ts(x?)$/, loader: 'babel-loader!ts-loader' },
{ test: /\.js$/, loader: 'ng-annotate!babel!jshint', exclude: /node_modules/ },
{ test: /\.json$/, loader: 'json-loader' }
]
},
plugins: [
new webpack.BannerPlugin('require("source-map-support").install();',
{ raw: true, entryOnly: false })
]
}
];
我哪里做错了?不用担心,找到了答案。嗯,在盯着代码的时候偶然发现的。我的配置中缺少以下内容:
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
}