-
Type: Task
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.1.16
-
Component/s: BSON
-
Environment:OS X El Capitan 10.11.4
npm 3.8.8
node 4.4.3
-
Empty show more show less
Hi,
I'm trying to bundle a js file, which uses mongodb, using browserify but I'm not able to. I receive the error
browserified.js:14223, BSON = require('bson').native().BSON
TypeError: require(...).native is not a function
The code is very simple
var MongoClient = require('mongodb').MongoClient; var x = "Hello NodeJS"; console.log(x); MongoClient.connect("mongodb://localhost:27017/test", (err, db) => { console.log("Error null? " + (err == null ? "YES" : "NO")); console.log("DB null? " + (db == null ? "YES" : "NO")); });
and I'm bundling it up using
bg. browserify simple.js -o browserified.js
I'm trying to use it in NodeJS. Someone in Stack Overflow pointed me to this https://github.com/substack/node-browserify#compatibility saying browserify shims some node modules to also work on the browser, so I don't know if it might be the case it is causing some problems in your implementation in case the driver is using any of those