Webpack moment.js无法找到模块

时间:2015-12-15 04:53:56

标签: momentjs webpack

我有webpack.config

var path = require('path');
var webpack = require('webpack');
var $https = require('https');
var BowerWebpackPlugin = require("bower-webpack-plugin");
module.exports = {
    context: __dirname + "/app/assets",
    entry: "./javascripts/core.js",
    output: {
        path: __dirname, //+ "/dist",
        filename: "./app/assets/javascripts/bundle.js",
        // export itself to a global var
        libraryTarget: "var",
        // name of the global var: "Foo"
        library: "Foo"
    },
    externals: {
        // require("jquery") is external and available
        //  on the global var jQuery
        //"jquery": "jQuery"
        'test2': 'test2'
    },
    plugins: [
       new BowerWebpackPlugin({
        modulesDirectories: ["bower_components"],
        manifestFiles:      "bower.json",
        includes:           /.*/,
        excludes:           [],
        searchResolveModulesDirectories: true
      }),
       new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery",
            "_": "underscore",
            //"moment": "moment",
            "window.jQuery": "jquery",
        }),
        new webpack.ResolverPlugin(
            new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
        )
    ],
    resolve: {
          root: [path.join(__dirname, "/public/bower_components"), path.join(__dirname, "/app/assets/javascripts")],

    module: {
        loaders: [
            { test: /\.js$/, loader: "script" },
            { test: /\.coffee$/, loader: "coffee" },
        ],
    },
    extensions: ['', '.js', '.json', '.coffee'],
    modulesDirectories: [__dirname + '/app/bower_components', __dirname + '/../node_modules'],
    alias: {
     'moment':  __dirname + '/public/bower_components/moment/moment'
      }           
    }

}

我在凉亭和npm安装时刻。但我仍然收到错误。

var moment = require ('moment');

在要求和构建项目webpack后生成输出

  ERROR in H:/minority-core/bp-web/public/bower_components/moment/moment.js
  Module not found: Error: Cannot resolve 'file' or 'directory' ./C:/Users/ё1/AppD
  ata/Roaming/npm/node_modules/webpack/buildin/module.js in H:\minority-core\bp-we
  b\public\bower_components\moment
  resolve file
    H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roa
  ming\npm\node_modules\webpack\buildin\module.js doesn't exist
    H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roa
  ming\npm\node_modules\webpack\buildin\module.js.js doesn't exist
    H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roa
  ming\npm\node_modules\webpack\buildin\module.js.json doesn't exist
    H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roa
  ming\npm\node_modules\webpack\buildin\module.js.coffee doesn't exist
  resolve directory
    H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roa
  ming\npm\node_modules\webpack\buildin\module.js doesn't exist (directory default
   file)
    H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roa
  ming\npm\node_modules\webpack\buildin\module.js\bower.json doesn't exist (direct
  ory description file)
    H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roa
  ming\npm\node_modules\webpack\buildin\module.js\package.json doesn't exist (dire
  ctory description file)
  [H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roam
  ing\npm\node_modules\webpack\buildin\module.js]
  [H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roam
  ing\npm\node_modules\webpack\buildin\module.js.js]
  [H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roam
  ing\npm\node_modules\webpack\buildin\module.js.json]
  [H:\minority-core\bp-web\public\bower_components\moment\C:\Users\ё1\AppData\Roam
  ing\npm\node_modules\webpack\buildin\module.js.coffee]
   @ H:/minority-core/bp-web/public/bower_components/moment/moment.js 1:0-83

我做错了什么以及如何解决? ................. ................. ................ ................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ..................................................

0 个答案:

没有答案