gpt4 book ai didi

node.js - 获取 TypeError : wsc. require is not a function for hyco-ws npm package

转载 作者:行者123 更新时间:2023-12-04 05:36:15 24 4
gpt4 key购买 nike

我想在当前可用的服务中使用这个 npm 包。当我运行“npm run start”时,它失败了并且我得到了错误:

TypeError: wsc.require is not a function at Object../node_modules/hyco-ws/lib/HybridConnectionWebSocketServer.js (D:\FreshClones\beconnect5******\lib\main.js:80851:24) at webpack_require (D:\FreshClones\beconnect5******\lib\main.js:21:30) at Object../node_modules/hyco-ws/index.js (D:\FreshClones\beconnect5******\lib\main.js:80686:20) at webpack_require (D:\FreshClones\beconnect5******\lib\main.js:21:30) at Object../source/backend/azure/EventGridClient.ts (D:\FreshClones\beconnect5******\lib\main.js:235598:20) at webpack_require (D:\FreshClones\beconnect5******\lib\main.js:21:30) at Object../source/backend/main.ts (D:\FreshClones\beconnect5\i******\lib\main.js:236679:27) at webpack_require (D:\FreshClones\beconnect5******\lib\main.js:21:30) at Object.0 (D:\FreshClones\beconnect5******\lib\main.js:238511:18) at webpack_require (D:\FreshClones\beconnect5******\lib\main.js:21:30) [web-serv] [nodemon] app crashed - waiting for file changes before starting...

这是在 main.js 文件中产生错误的代码行:

var wsc = __webpack_require__.c[/*require.resolve*/(/*! ws */ "./node_modules/hyco-ws/node_modules/ws/index.js")]

const Extensions = wsc.require('./lib/Extensions');

注意“******”指的是我出于隐私原因隐藏的文件夹名称。

最佳答案

所以我自己解决了,很简单。

我们有一个 webpack.config.backend.js 设置,它在“npm run build”之后将模块导出到 lib 文件夹的 Node 模块中。只需将我的包添加到 module.exports 中即可。

    module.exports =  {
externals: ['utf-8-validate', 'bufferutil',{
"hyco-ws": "hyco-ws",
.................. ,
.................. ,
}]
};

关于node.js - 获取 TypeError : wsc. require is not a function for hyco-ws npm package,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58955254/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com