Typescript 未找到模块:错误:Can';t解决';ts装载机&x27;
以下是我的webpack.config.jsTypescript 未找到模块:错误:Can';t解决';ts装载机&x27;,typescript,webpack,ts-loader,Typescript,Webpack,Ts Loader,以下是我的webpack.config.js var webpack = require('webpack'), path = require('path'), yargs = require('yargs'); var libraryName = 'MyLib', plugins = [], outputFile; if (yargs.argv.p) { plugins.push(new webpack.optimize.UglifyJsPlugin({
var webpack = require('webpack'),
path = require('path'),
yargs = require('yargs');
var libraryName = 'MyLib',
plugins = [],
outputFile;
if (yargs.argv.p) {
plugins.push(new webpack.optimize.UglifyJsPlugin({
minimize: true
}));
outputFile = libraryName + '.min.js';
} else {
outputFile = libraryName + '.js';
}
var config = {
entry: [
__dirname + '/src/TestClass.ts'
],
devtool: 'source-map',
output: {
path: path.join(__dirname, '/dist'),
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
rules: [{
test: /\.tsx?$/,
use: 'ts-loader', //Something wrong here
exclude: /node_modules/
}]
},
resolve: {
modules: [__dirname],
extensions: ['.ts', '.js', '.tsx']
},
plugins: plugins
};
module.exports = config;
这是一个打字脚本项目
当我使用WebpackVersion4.5.0运行build并缩小typescript项目时,我得到以下错误
未找到模块:错误:无法解析“ts加载程序”
不知道怎么了
我使用ts加载器版本4.2.0
Typescript版本2.8.1
敬请告知。确保已安装ts loader并将其添加到规则中:
npm install -D ts-loader
及
你安装了ts加载器吗?在您的package.json dev依赖项中?我的行看起来一样:{test://\.ts$/,use:[{loader:'ts loader',options:{silent:true}},'angular router loader']},我使用的是ts loader 2.2.2,您使用的是非常高级的typescript versionyeah。我已经安装了ts加载器。它在dev dependencies下的package.json中。您是否尝试过{loader:'ts loader'}而不是'ts-loader'。这个答案并不能解释为什么npm没有在package.json中安装ts loader。在我的例子中,我只需要重新启动VS
module: {
rules: [
{test: /\.ts$/, exclude: /node_modules/, loader: 'ts-loader'}
]
},