我正在使用npm install socket.io-stream
我在我的 Angular 组件上实现了 socket.io-stream
,如下所示:
import * as io from 'socket.io-client';
import * as ss from 'socket.io-stream';
我只想创建一个像这样的双工流:
stream=ss.createStream();
运行 ng build
时出现此错误:
ERROR in ./node_modules/socket.io-stream/lib/iostream.js
Module not found: Error: Can't resolve 'stream' in '
'C:\Users\geoffroy\Documents\Mines Alès\2A\Stage\WebService based
GUI\WebApp\node_modules\socket.io-stream\lib'
ERROR in ./node_modules/socket.io-stream/lib/blob-read-stream.js
Module not found: Error: Can't resolve 'stream' in
'C:\Users\geoffroy\Documents\Mines Alès\2A\Stage\WebService based
GUI\WebApp\node_modules\socket.io-stream\lib'
我不明白,因为在我的 server.js 上它似乎可以工作..
我尝试运行命令 npm install stream
并且 ng build
没有出现错误。但是当我启动我的应用程序时,我的浏览器控制台中出现了一个新错误:
inherits_browser.js:5 Uncaught TypeError: Cannot read property 'prototype' of undefined
at Object.inherits (inherits_browser.js:5)
at Object../node_modules/socket.io-stream/lib/iostream.js (iostream.js:10)
at __webpack_require__ (bootstrap:76)
at Object../node_modules/socket.io-stream/lib/socket.js (socket.js:4)
at __webpack_require__ (bootstrap:76)
at Object../node_modules/socket.io-stream/lib/index.js (index.js:1)
at __webpack_require__ (bootstrap:76)
at Object../node_modules/socket.io-stream/index.js (index.js:2)
at __webpack_require__ (bootstrap:76)
感谢您的帮助
最佳答案
只需在polyfills.ts中添加这一行
//将全局添加到窗口,分配窗口本身的值。
(任意窗口).global = window;
关于node.js - Angular 6 中的 socket.io-stream 导入问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51478359/