React webpack bundle

时间:2016-11-20 17:11:51

标签: node.js reactjs webpack ecmascript-6

我遇到了webpack的问题。我的webpack.config.js文件列在下面。在重新安装我的mac之前,它工作正常。现在我收到了这个错误:

Module build failed: Error: Couldn't find preset "es2015" relative to directory

所有依赖项都没问题,我已多次尝试删除node_modules并重新安装它们。有人可以帮我解决这个问题吗?

const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

const DIST_DIR = path.resolve(__dirname, "assets/dist/bundles");
const SRC_DIR = path.resolve(__dirname, "assets/src");

const ENV = process.env.NODE_ENV || 'production';

module.exports = {
    entry: [
        SRC_DIR + "/js/index.js",
        SRC_DIR + "/scss/index.scss"
    ],
    output: {path: DIST_DIR, filename: 'bundle.js'},
    plugins: [
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify(ENV)
            }
        }),
        new ExtractTextPlugin("bundle.css")
    ],
    module: {
        loaders: [
            {
                test: /\.scss$/,
                loader: ExtractTextPlugin.extract(
                    "css!sass")
            },
            {
                test: [/\.js$/, /\.es6$/],
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                  cacheDirectory: true,
                  presets: ['react', 'es2015'],
                }
              }
        ]
    }
};

Package.json依赖项是:

  "dependencies": {
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.7",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react": "^6.16.0",
    "body-parser": "~1.15.1",
    "bulma": "^0.2.3",
    "cookie-parser": "~1.4.3",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.25.0",
    "debug": "~2.2.0",
    "express": "~4.13.4",
    "extract-text-webpack-plugin": "^1.0.1",
    "morgan": "~1.7.0",
    "node-sass": "^3.13.0",
    "pug": "^2.0.0-beta5",
    "react": "^15.4.0",
    "react-dom": "^15.4.0",
    "sass-loader": "^4.0.2",
    "serve-favicon": "~2.3.0",
    "webpack": "^1.13.3"
  }

0 个答案:

没有答案