繁体   English   中英

如何修复错误[ERR_ASSERTION]:构造函数已经存在! (“inversify-restify-utils”:“^ 3.4.0”)和(“inversify-restify-utils”:“^ 3.4.0”)

[英]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]:构造函数已经存在!

"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

堆栈跟踪

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

该模块附带了一组构造函数,可用于使用默认状态代码创建Error对象。

npm i restify-errors --save-dev

只需将此软件包安装到您的项目中,因为在您使用Inversifyjs时需要它

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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