tty.js icon indicating copy to clipboard operation
tty.js copied to clipboard

TypeError: Cannot read property 'prototype' of undefined

Open blackmiaool opened this issue 8 years ago • 18 comments

/.nvm/versions/node/v7.1.0/lib/node_modules/tty.js/node_modules/socket.io/lib/transports/websocket/hybi-07-12.js:449 Parser.prototype.proto = EventEmitter.prototype; ^

TypeError: Cannot read property 'prototype' of undefined at Object. (/home/blackmiaool/.nvm/versions/node/v7.1.0/lib/node_modules/tty.js/node_modules/socket.io/lib/transports/websocket/hybi-07-12.js:449:42) at Module._compile (module.js:573:32) at Object.Module._extensions..js (module.js:582:10) at Module.load (module.js:490:32) at tryModuleLoad (module.js:449:12) at Function.Module._load (module.js:441:3) at Module.require (module.js:500:17) at require (internal/module.js:20:19) at Object. (/home/blackmiaool/.nvm/versions/node/v7.1.0/lib/node_modules/tty.js/node_modules/socket.io/lib/transports/websocket/index.js:7:6) at Module._compile (module.js:573:32)

Solution: 1 Enter ~/.nvm/versions/node/v7.1.0/lib/node_modules/tty.js/node_modules/socket.io/lib/ (change v7.1.0 to your node edition or redirect it to your node folder it you don't use nvm) 2 Replace "EventEmitter = process.EventEmitter" with "EventEmitter = require('events')" 3 Save and retry.

blackmiaool avatar Dec 04 '16 05:12 blackmiaool

It would be better if you upgrade to the newest socket.io.

blackmiaool avatar Dec 04 '16 05:12 blackmiaool

Seems this repo is not maintained any more. I'll focus on my own fork. https://github.com/blackmiaool/tty.js

blackmiaool avatar Dec 07 '16 12:12 blackmiaool

+1

qeesung avatar Dec 27 '16 02:12 qeesung

Any solutions on that? Also the clone of blackmaool still has the same problem. Looking forward for a fix.

LosWochos76 avatar Dec 27 '16 11:12 LosWochos76

BTW: Which version do I get by "npm install tty"? This one or the clone from backmiaool? Maybe it makes sense to rename the clone to e.g. tty2 and publish it under that new name in the npm registry?

LosWochos76 avatar Dec 27 '16 11:12 LosWochos76

@LosWochos76 I tried to install my fork again on my linux and found it worked well. Could you check your installation of my fork?

blackmiaool avatar Dec 27 '16 12:12 blackmiaool

@qeesung @LosWochos76 This problem is caused by deprecation of old style event emitter in node7. The emitter is used by the old edition of socket.io. The solution to the problem is copying the socket.io module to root directory of this module, updating the event emitter style of it, and referring it in this module. Or you can migrate the socket.io in this module to new edition.

blackmiaool avatar Dec 27 '16 12:12 blackmiaool

Sorry, but the fork does not work. Installing it with git clone https://github.com/blackmiaool/tty.js I face multiple problems:

  1. When I start the service via with "node index.js", I et an error due to missing dependency socket.io-client. The package.json seems to miss that. But it can be fixed by installing it manually.

  2. Now I can run the command, but opening the browser and connecting to the service throws the following error:

tty.js/tty.js/socket.io/lib/static.js:100 client.builder(transports, { ^

TypeError: client.builder is not a function

LosWochos76 avatar Dec 28 '16 19:12 LosWochos76

@LosWochos76 Sorry. I found the problem. You can fix it by entering socket.io directory and execute "npm install" or pulling the newest repo.

blackmiaool avatar Dec 29 '16 01:12 blackmiaool

@chjj hi I am using the term.js The is the plug-in to complex paste?

wlLeblanc avatar Dec 29 '16 10:12 wlLeblanc

https://github.com/risacher/ttyx is a fork that replaces term.js with xterm.js, updates socket.io to version 1.x and updates Express to version 4.x.

Hope this helps.

risacher avatar Feb 10 '17 18:02 risacher

god ! this have to many error, how to deal with it?

TypeError: Cannot read property 'prototype' of undefined at Object. (/home/node_modules/socket.io/lib/store.js:35:41) at Module._compile (module.js:569:30) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3) at Module.require (module.js:513:17) at require (internal/module.js:11:18) at Object. (/home/node_modules/socket.io/lib/manager.js:16:13) at Module._compile (module.js:569:30)

easydowork avatar Jul 01 '17 06:07 easydowork

@risacher TypeError: express.basicAuth is not a function

hugywin avatar Jul 03 '17 07:07 hugywin

I am facing this issue when i run command gulp serve-dev

E:\xampp\htdocs\ng-demos\modular\node_modules\karma\node_modules\socket.io\lib\store.js:35 Store.prototype.proto = EventEmitter.prototype; ^

TypeError: Cannot read property 'prototype' of undefined at Object. (E:\xampp\htdocs\ng-demos\modular\node_modules\karma\node_modules\socket.io\lib\store.js:35:42) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at Object. (E:\xampp\htdocs\ng-demos\modular\node_modules\karma\node_modules\socket.io\lib\manager.js:16:13) at Module._compile (module.js:635:30)

hassanuos avatar Jan 26 '18 17:01 hassanuos

Looks like you need to upgrade your socket.io version. Older versions use var EventEmitter = process.EventEmitter which is deprecated. You need versions that use var EventEmitter = require('events')

pak11273 avatar Jan 28 '18 22:01 pak11273

@hassanuos If you update socket.io to latest version you have to modify also the code (in tty.js remove io.configure(..)). The fastest solution is to change node_modules/tty.js/package.json and set "socket.io": "0.9.19",. Complete with npm install from tty.js path and it works.

tmac12 avatar Feb 02 '18 16:02 tmac12

Well, i tried many solutions from all the above options. i found the real problem to be node version. I have updated to node v10 however the application was built 3 years ago. when EventEmitter was available via process therefore a lot of old libraries were referencing it from process directly.

Also wanted to mention, i did not have issue specific to tty.js, but it was karma not running tests with angularjs 1.

solution

  1. remove node_modules
  2. nvm use v5.12.0
  3. npm i

started the app again, and it was working.

Peripona avatar Nov 06 '18 13:11 Peripona

@hassanuos 如果将socket.io更新到最新版本,则还必须修改代码(在tty.js中,删除io.configure(..))。 最快的解决方案是更改node_modules / tty.js / package.json并设置"socket.io": "0.9.19",。从tty.js路径 完成npm install并可以正常工作。

good

yunliang-ding avatar Oct 25 '19 07:10 yunliang-ding