找不到Lodash模块+ Webpack

找不到Lodash模块+ Webpack

问题描述:

我尝试使用Ladash库,但出现下一个错误:

I try use the library ladash but I´m getting the next error:

Module not found: Error: Can't resolve 'lodash' in

我将库导入为:

import _ from 'lodash';

这是webpack配置:

This is the webpack config:

{
  loader: 'babel-loader',
  test: /\.js$/,
  exclude: /node_modules/,
  options: {
     plugins: ['lodash'],
     presets: [['env', { modules: false, targets: { node: 4 } }]]
  }
}

......
......
plugins: [
   new LodashModuleReplacementPlugin,
   new webpack.optimize.UglifyJsPlugin
]

这是我的包json依赖项:

and this is my package json dependencies:

运行 npm install 将解决您的错误!