Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot use 'in' operator to search for 'promiseLibrary' in myproj #6756

Closed
denizdogan opened this issue Jul 22, 2018 · 1 comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone

Comments

@denizdogan
Copy link

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

/Users/deniz/Code/myproj/node_modules/mongoose/lib/connection.js:463
  if (!('promiseLibrary' in options)) {
                         ^

TypeError: Cannot use 'in' operator to search for 'promiseLibrary' in myproj
    at NativeConnection.Connection.openUri (/Users/deniz/Code/myproj/node_modules/mongoose/lib/connection.js:463:26)
    at Mongoose.createConnection (/Users/deniz/Code/myproj/node_modules/mongoose/lib/index.js:189:17)
    at Object.<anonymous> (/Users/deniz/Code/myproj/dist/index.js:19:36)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:236:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)

If the current behavior is a bug, please provide the steps to reproduce.

import mongoose from 'mongoose'

const connection = mongoose.createConnection(
  process.env.MONGODB_HOST,
  process.env.MONGODB_DATABASE,
  process.env.MONGODB_PORT
)

export default connection

...or transpiled...

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _mongoose = _interopRequireDefault(require("mongoose"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var connection = _mongoose.default.createConnection(process.env.MONGODB_HOST, process.env.MONGODB_DATABASE, process.env.MONGODB_PORT);

var _default = connection;
exports.default = _default;

I've verified that the values in process.env are valid.

What is the expected behavior?

Expected is no error or better error message

Please mention your node.js, mongoose and MongoDB version.

  • Node 10.6.0
  • mongoose 5.2.4
  • MongoDB 4.0.0
@lineus
Copy link
Collaborator

lineus commented Jul 24, 2018

The parameter signature you are using with createConnection() is no longer valid as of mongoose 5, covered in the migration guide here.

I noticed that the mongoose 5 docs still have this specific signature in the api docs' createConnection example. I will put in a PR to remove this example momentarily.

@vkarpov15 vkarpov15 added this to the 5.2.6 milestone Jul 25, 2018
@vkarpov15 vkarpov15 added docs This issue is due to a mistake or omission in the mongoosejs.com documentation enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature and removed docs This issue is due to a mistake or omission in the mongoosejs.com documentation labels Jul 25, 2018
vkarpov15 added a commit that referenced this issue Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Projects
None yet
Development

No branches or pull requests

3 participants