Skip to content

[ERR_ASSERTION]: Constructor already exists! (restify@7.1.1 + inversify-restify-utils@3.3.1)Β #847

@hlibco

Description

@hlibco

Similar to the closed issue #703 (but with a newer version of restify)

Expected Behavior

It should start the restify server without problems.

Current Behavior

As soon as restify is imported an error is thrown: [ERR_ASSERTION]: Constructor already exists!

Possible Solution

To use inversify-restify-utils@3.3.1 I had to downgrade Restify to restify@6.3.2

Steps to Reproduce (for bugs)

Clone the following repo: https://github.com/hlibco/restify-inversify-constructor-error

  1. install dependencies yarn install or npm install
  2. run yarn start or npm start
  3. you should get the error
node_modules/restify-errors/lib/index.js:67
    assert.equal(typeof module.exports[name], 'undefined',
           ^
AssertionError [ERR_ASSERTION]: Constructor already exists!

Your Environment

  • node v9.4.0
    "inversify": "4.11.1",
    "inversify-restify-utils": "3.3.1",
    "reflect-metadata": "^0.1.12",
    "restify": "7.1.1",

Stack trace

/Users/earth/git-public/restify-inversify-problem/node_modules/restify-errors/lib/index.js:67
    assert.equal(typeof module.exports[name], 'undefined',
           ^
AssertionError [ERR_ASSERTION]: Constructor already exists!
    at Object.makeConstructor (/Users/earth/git-public/restify-inversify-problem/node_modules/restify-errors/lib/index.js:67:12)
    at Object.<anonymous> (/Users/earth/git-public/restify-inversify-problem/node_modules/restify/lib/errorTypes.js:5:8)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/earth/git-public/restify-inversify-problem/node_modules/restify/lib/index.js:14:1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions