I am working through a Node.js tutorial and we just started working with Mongoose. Everything has been going great until today. I turned on my computer and opened WebStorm. I went to run what we had last worked on and I get the following stack trace:
/usr/bin/node /home/doug/Documents/node-course/task-manager/src/db/mongoose.js
/home/doug/Documents/node-course/task-manager/node_modules/bson/index.js:41
BSON.BSONRegExp = BSONRmgExp;
^
ReferenceError: BSONRmgExp is not defined
at Object.<anonymous> (/home/doug/Documents/node-course/task-manager/node_modules/bson/index.js:41:19)
at Module._compile (internal/modules/cjs/loader.js:1236:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
at Module.load (internal/modules/cjs/loader.js:1085:32)
at Function.Module._load (internal/modules/cjs/loader.js:950:14)
at Module.require (internal/modules/cjs/loader.js:1125:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/home/doug/Documents/node-course/task-manager/node_modules/mongodb/lib/core/index.js:3:12)
at Module._compile (internal/modules/cjs/loader.js:1236:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
Process finished with exit code 1
Here is the code I have:
const mongoose = require('mongoose');
//
// // mongoose.connect('mongodb://127.0.0.1:27017/task-manager-api', {
// // useNewUrlParser: true,
// // useCreateIndex: true
// // });
//
// // const User = mongoose.model('User', {
// // name: {
// // type: String,
// // },
// // age: {
// // type: Number
// // }
// // });
//
//
// // const Task = mongoose.model('Task', {
// // description: {
// // type: String
// // },
// // completed: {
// // type: Boolean
// // }
// // });
//
// //
// // const newTask = new Task({
// // description: 'This is a new task added by mongoose.',
// // completed: false
// // });
// //
// // newTask.save().then((newTask) => {
// // console.log(newTask);
// // }).catch((error) => {
// // console.log('Error!', error);
// // });
//
// // const me = new User({
// // name: 'Doug',
// // age: 30
// // });
// //
// // me.save().then((me) => {
// // console.log(me);
// // }).catch((error) => {
// // console.log('Error!', error);
// // });
With everything commented out except for my require, I still get the error. If I comment out require, it runs.
Searching "ReferenceError: BSONRmgExp is not defined" is bringing up nothing that I can find.
Does anyone have a suggestion as to how I can fix this or what is causing it?
EDIT: Here is the file it is referencing which is located in the node_modules folder.
index.js
var BSON = require('./lib/bson/bson'),
Binary = require('./lib/bson/binary'),
Code = require('./lib/bson/code'),
DBRef = require('./lib/bson/db_ref'),
Decimal128 = require('./lib/bson/decimal128'),
Double = require('./lib/bson/double'),
Int32 = require('./lib/bson/int_32'),
Long = require('./lib/bson/long'),
Map = require('./lib/bson/map'),
MaxKey = require('./lib/bson/max_key'),
MinKey = require('./lib/bson/min_key'),
ObjectId = require('./lib/bson/objectid'),
BSONRegExp = require('./lib/bson/regexp'),
Symbol = require('./lib/bson/symbol'),
Timestamp = require('./lib/bson/timestamp');
// BSON MAX VALUES
BSON.BSON_INT32_MAX = 0x7fffffff;
BSON.BSON_INT32_MIN = -0x80000000;
BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1;
BSON.BSON_INT64_MIN = -Math.pow(2, 63);
// JS MAX PRECISE VALUES
BSON.JS_INT_MAX = 0x20000000000000; // Any integer up to 2^53 can be precisely represented by a double.
BSON.JS_INT_MIN = -0x20000000000000; // Any integer down to -2^53 can be precisely represented by a double.
// Add BSON types to function creation
BSON.Binary = Binary;
BSON.Code = Code;
BSON.DBRef = DBRef;
BSON.Decimal128 = Decimal128;
BSON.Double = Double;
BSON.Int32 = Int32;
BSON.Long = Long;
BSON.Map = Map;
BSON.MaxKey = MaxKey;
BSON.MinKey = MinKey;
BSON.ObjectId = ObjectId;
BSON.ObjectID = ObjectId;
// BSON.BSONRegExp = BSONRmgExp;
BSON.Symbol = Symbol;
BSON.Timestamp = Timestamp;
// Return the BSON
module.exports = BSON;
If I comment out the line "BSON.BSONRegExp = BSONRmgExp;", then everything runs. I tried searching Google for the line in quotations and it has no results.
EDIT 2: I'm guessing it has something to do with MongoDB but the documentation isn't very helpful for this specific issue.
Tried BSON.BSONRegExp = BSONRegExp;
instead of BSON.BSONRegExp = BSONRmgExp;
?
User contributions licensed under CC BY-SA 3.0