xwartz / xwartz.github.com

Home Page
https://xwartz.github.com/
1 stars 0 forks source link

解决 webpack 使用 node 模块报错 #30

Closed xwartz closed 7 years ago

xwartz commented 8 years ago

正好在使用 webpack 开发 electric 应用的时候碰到这个问题

比如想使用 request 模块,就会报如下错误

ERROR in ~/request/lib/har.js
Module not found: Error: Cannot resolve module 'fs' in /node_modules/dbfm-app-sdk/node_modules/request/lib
 @ ./~/request/lib/har.js 3:9-22

解决方法可以是: 1.配置 node, 这并不好,相当于模块无作用了

node: {
    fs: 'empty'
}

http://webpack.github.io/docs/configuration.html#node

2.更改 target http://webpack.github.io/docs/configuration.html#target