简体   繁体   中英

How to fixed the error [ERR_ASSERTION]: Constructor already exists! (“inversify-restify-utils”: “^3.4.0”) and ( “inversify-restify-utils”: “^3.4.0”)

node_modules/restify-errors/lib/index.js:67 assert.equal(typeof module.exports[name], 'undefined', ^ AssertionError [ERR_ASSERTION]: Constructor already exists!

"inversify": "^4.13.0",
"inversify-binding-decorators": "^4.0.0",
"inversify-restify-utils": "^3.4.0",
"js-yaml": "^3.12.0",
"lodash": "^4.17.11",
"reflect-metadata": "^0.1.12",
"restify": "^7.2.1",
"restify-cors-middleware": "^1.1.1",
"winston": "^3.0.0"
private setPlugins(): void {
        const cors = corsMiddleware(this.config.cors);

        this.server.pre(cors.preflight);

    this.server.use(
        restify.plugins.acceptParser(this.server.acceptable),
        cors.actual
    );
}

It should able to run

npm run serve

Stack Track

/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)

This module ships with a set of constructors that can be used to new up Error objects with default status codes.

npm i restify-errors --save-dev

just install this package to your project because it is required when you use for the Inversifyjs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM