vue-cli webpack-simple, mongodb require 问题
Vue-cli webpack-simple, mongodb require problems
我正在尝试使用 webpack-simple 模板通过 vue-cli 创建一个新项目。一切正常,直到我尝试使用 mongodb.
只要我添加行
import mongodb from 'mongodb'
我收到以下错误。
./node_modules/mongodb/lib/gridfs/grid_store.js Module not found: Error: Can't resolve 'fs' in 'D:\Development\vue-cli-test\node_modules\mongodb\lib\gridfs'
我在添加
时摆脱了这个错误
node: { fs: 'empty' }
到我的 webpack.config.js 文件。
现在我得到以下错误
./node_modules/require_optional/node_modules/resolve-from/index.js Module not found: Error: Can't resolve 'module' in 'D:\Development\vue-cli-test\node_modules\require_optional\node_modules\resolve-from'
我使用节点版本 8.9.0
非常感谢
fs/MongoDB不能在前端代码中使用。将数据发送到服务器,然后让服务器将其保存到数据库。
我正在尝试使用 webpack-simple 模板通过 vue-cli 创建一个新项目。一切正常,直到我尝试使用 mongodb.
只要我添加行
import mongodb from 'mongodb'
我收到以下错误。
./node_modules/mongodb/lib/gridfs/grid_store.js Module not found: Error: Can't resolve 'fs' in 'D:\Development\vue-cli-test\node_modules\mongodb\lib\gridfs'
我在添加
时摆脱了这个错误node: { fs: 'empty' }
到我的 webpack.config.js 文件。
现在我得到以下错误
./node_modules/require_optional/node_modules/resolve-from/index.js Module not found: Error: Can't resolve 'module' in 'D:\Development\vue-cli-test\node_modules\require_optional\node_modules\resolve-from'
我使用节点版本 8.9.0
非常感谢
fs/MongoDB不能在前端代码中使用。将数据发送到服务器,然后让服务器将其保存到数据库。