未捕获错误:[$ injector:modulerr]由于以下原因无法实例化模块uoApp.commerce: 错误:找不到模块"。"
at webpackMissingModule(file:/// C:/Users/206560/projects/uo-com-commerce/dist/commerce.bundle.js:164943:63)
在CommerceRouteConfig(file:/// C:/Users/206560/projects/uo-com-commerce/dist/commerce.bundle.js:164943:141)
at Object.invoke(file:/// C:/Users/206560/projects/uo-com-commerce/dist/commerce.bundle.js:123600:19)
at runInvokeQueue(file:/// C:/Users/206560/projects/uo-com-commerce/dist/commerce.bundle.js:123487:35)
在file:/// C:/Users/20656/projects/uo-com-commerce/dist/commerce.bundle.js:123497:11
我想将angular1.x与typescript和webpack-3
一起使用tsconfig
{
"compilerOptions": {
"outDir": "./dist/",
"moduleResolution": "node",
"noImplicitAny": false,
"sourceMap": true,
"target": "es5",
"allowJs": true
}
}
Module.ts文件 `
import { SharedModule } from '../../shared/src/shared.module';
import '../node_modules/angular-update-meta/dist/update-meta';
import '../node_modules/angular-material/angular-material';
import '../node_modules/angular-animate/angular-animate';
import '../node_modules/angular-aria/angular-aria';
angular
.module('uoApp.commerce', [
'updateMeta',
require('angular-aria'),
require('angular-animate'),
require('angular-material'),
SharedModule
])
`
我的 webpack.config 文件如下所示:
/*eslint-disable*/
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: './src/commerce.module.ts',
module: {
rules: [
{
test: /\.html?$/,
use: 'html-loader',
exclude: /node_modules/
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: require.resolve('jquery'),
use: [{
loader: 'expose-loader',
options: 'jQuery'
}, {
loader: 'expose-loader',
options: '$'
}]
},
{
test: require.resolve('bluebird'),
use: {
loader: 'expose-loader',
options: 'Promise'
}
},
{
test: require.resolve('lodash'),
use: {
loader: 'expose-loader',
options: '_'
}
},
{
test: require.resolve('moment'),
use: {
loader: 'expose-loader',
options: 'moment'
}
},
{
test: require.resolve('angular'),
use: {
loader: 'expose-loader',
options: 'angular'
}
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
plugins: [
new CleanWebpackPlugin(['dist']),
// new HtmlWebpackPlugin({
// title: 'Production'
// })
],
output: {
filename: 'commerce.bundle.js',
path: path.resolve(__dirname, 'dist')
}
};
我如何知道导致错误的原因?如果它不是导致它的webpack.config.js,我还应该检查什么?