Как исправить ошибку [ERR_ASSERTION]: конструктор уже существует!("inversify-restify-utils": "^ 3.4.0") и ("inversify-restify-utils": "^ 3.4.0") - PullRequest
0 голосов
/ 26 марта 2019

node_modules / restify-ошибки / Lib / index.js: 67 assert.equal (typeof module.exports [name], 'undefined', ^ AssertionError [ERR_ASSERTION]: конструктор уже существует!

"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
    );
}

Он должен быть в состоянии запустить

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)

1 Ответ

0 голосов
/ 02 апреля 2019

Этот модуль поставляется с набором конструкторов, которые можно использовать для создания новых объектов Error с кодами состояния по умолчанию.

npm i restify-errors --save-dev

просто установите этот пакет в свой проект, поскольку он требуется при использовании дляInversifyjs

...