chjj / tty.js

A terminal for your browser, using node/express/socket.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read property 'prototype' of undefined

blackmiaool opened this issue · 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.

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

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

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

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 I tried to install my fork again on my linux and found it worked well. Could you check your installation of my fork?

@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.

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 Sorry. I found the problem. You can fix it by entering socket.io directory and execute "npm install" or pulling the newest repo.

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

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.

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)

@risacher TypeError: express.basicAuth is not a function

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)

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

@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.

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.

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

good