Webpacl解析和模块未找到错误

时间:2017-05-16 07:29:45

标签: webpack webpack-2

得到如下错误:

[INFO] ERROR in ./~/redbox-react/lib/index.js
[INFO] Module not found: Error: Can't resolve 'error-stack-parser' in 'myPath\node_modules\redbox-react\lib'
[INFO]  @ ./~/redbox-react/lib/index.js 28:24-53
[INFO]  @ ./src/router/privateRoute.js
[INFO]  @ ./src/router/Router.js
[INFO]  @ ./src/index.js
[INFO]  @ multi webpack-hot-middleware/client ./src/index
[INFO] 
[INFO] ERROR in ./~/redbox-react/lib/index.js
[INFO] Module not found: Error: Can't resolve 'object-assign' in 'myPath\node_modules\redbox-react\lib'
[INFO]  @ ./~/redbox-react/lib/index.js 32:20-44
[INFO]  @ ./src/router/privateRoute.js
[INFO]  @ ./src/router/Router.js
[INFO]  @ ./src/index.js
[INFO]  @ multi webpack-hot-middleware/client ./src/index

我的webpack.config.js文件:

var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var jeet = require('jeet');
var nib = require('nib');

module.exports = {
  devtool: 'inline-source-map',
  entry: [
    'webpack-hot-middleware/client',
    './src/index'
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
    publicPath: '/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.DefinePlugin({
      "process.env": {
        NODE_ENV: JSON.stringify('development')
      }
    }),
    new HtmlWebpackPlugin({
      title: 'Boot React',
      template: path.join(__dirname, 'src/assets/index-template.html')
    })
  ],
  resolve: {
    extensions: ['.js'],
    modules: [
      path.resolve(__dirname, 'src'),
      "node-modules"
    ]
  },
  module: {
    rules: [{
      test: /\.js$/,
      exclude: /node_modules/,
      include: path.join(__dirname, 'src'),
      use: [
        {
          loader: 'babel-loader',
          options: {
            cacheDirectory: true
          }
        }
      ]
    },
      {
        test: /\.styl$/i,
        use: [
          {loader: 'style-loader'},
          {loader: 'css-loader'},
          {loader: 'stylus-loader'},
          jeet(),
          nib()
        ]
      }
      ,
      {
        test: /\.css$/,
        use: [
          {loader: "style-loader"},
          {
            loader: "css-loader",
            options: {modules: true}
          }
        ]
      }
    ]
  }
}
;

尝试过很多教程,但没有任何帮助。任何想法,为什么我收到这些错误?我正在尝试从Webpack 1.x迁移到Webpack 2.x.已经重写了我的webpack.config.js,babelrc和package.json文件。

1 个答案:

答案 0 :(得分:0)

我对此问题的解决方案是完全删除此部分:

 resolve: {
    extensions: ['.js'],
    modules: [
      path.resolve(__dirname, 'src'),
      "node-modules"
    ]
  }