用力矩加载 angular-力矩 - 错误 'module' 不是函数

Load angular-moment with moment - Error 'module' is not a function

我遇到了一些问题,包括使用 webpack 的 angular-moment 包。 假设在我的文件 app.js 中,我以这种方式包含文件依赖项:

import 'moment/src/moment';
import angularMoment from 'angular-moment';
angular.module('helloWorldapp', [angularMoment]);

我的webpack.config如下:

    var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
var webpackUglifyJsPlugin = require('webpack-uglify-js-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');


const extractCSS = new ExtractTextPlugin('[name][hash].css');
const extractSCSS = new ExtractTextPlugin('[name][hash].css');
const commonsPlugin = new CommonsChunkPlugin('vendor.js');
const htmlPlugin = new HtmlWebpackPlugin({
    template: path.join(__dirname, '/client/index.html'),
    filename: '../client/index.html',
    inject: 'true'
});
const providePlugin = new webpack.ProvidePlugin({
    '$': 'jquery',
    'jQuery': 'jquery',
    'window.jQuery': 'jquery',
     'window.moment': 'moment'
});

module.exports = {
    entry: {
        app: './client/app/app.js',
        vendor: [
            'angular',
            'angular-animate',
            'angular-aria',
            'angular-cookies',
            'angular-resource',
            'angular-messages',
            'angular-sanitize',
            'angular-socket-io',
            'angular-ui-bootstrap',
            'angular-ui-router',
            'moment',
            'angular-moment',
            'angular-material',
            'angular-translate',
            'angular-translate-loader-partial',
            'lodash',
            'mobile-detect',
            'angular-local-storage'
        ]
    },
    output: {
        path: path.join(__dirname, '/dist/client'),
        filename: '[name][hash].js'
    },
    plugins: [extractCSS, extractSCSS, htmlPlugin, commonsPlugin, providePlugin], // uglifyCode
    debug: true,
    module: {
        loaders: [
            {
                test: /\.css$/,
                loader: extractCSS.extract(
                    'css',
                    'sass'
                )
            },
            {
                // SASS LOADER
                // Reference: https://github.com/jtangelder/sass-loader
                test: /\.(scss|sass)$/,
                loader: ExtractTextPlugin.extract(
                    'style',
                    'css!sass!resolve-url!sass?sourceMap'
                )
            },
            {
             test: /\.scss$/,
             loader: ExtractTextPlugin.extract(
             'style',
             'css!sass!resolve-url!sass?sourceMap'
             ),
             include: [path.resolve(__dirname, 'client/app/app.scss')],
             // exclude: [path.resolve(__dirname, 'client/bower_components'), path.resolve(__dirname, 'node_modules')]
             },*/
            {
                test: /\.js$/, loaders: ['ng-annotate', 'babel-loader'], include: [
                path.resolve(__dirname, 'client/')
                // path.resolve(__dirname, 'node_modules/lodash-es/')
            ]
            },
            {
                test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)([\?]?.*)$/,
                loader: 'file'
            },
            {
                include: /\.json$/,
                loaders: ['json-loader']
            }
        ]
    },

};

angular-moment 的版本是最后一个可用版本 (v1.0.0-beta.6)。我也阅读了 https://github.com/urish/angular-moment/issues/108 但我无法找到正确的解决方案。 错误总是一样的:'Error 'module' is not a function'

有人知道我哪里错了吗?

应该是这样的,

angular.module('helloWorldapp', ['angularMoment']);