未找到Lodash模块+ webpack

时间:2017-11-04 11:06:01

标签: webpack lodash

我尝试使用库ladash,但我收到了下一个错误:

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

我将库导入为:

import _ from 'lodash';

这是webpack配置:

{
  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依赖项:

enter image description here

1 个答案:

答案 0 :(得分:1)

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