Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'prototype' of undefined #168

Open
blackmiaool opened this issue Dec 4, 2016 · 18 comments
Open

TypeError: Cannot read property 'prototype' of undefined #168

blackmiaool opened this issue Dec 4, 2016 · 18 comments

Comments

@blackmiaool
Copy link

/.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
Copy link
Author

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

@blackmiaool
Copy link
Author

blackmiaool commented Dec 7, 2016

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

@qeesung
Copy link

qeesung commented Dec 27, 2016

+1

@LosWochos76
Copy link

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

@LosWochos76
Copy link

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?

@blackmiaool
Copy link
Author

@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
Copy link
Author

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

@LosWochos76
Copy link

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

@blackmiaool
Copy link
Author

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

@wlLeblanc
Copy link

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

@risacher
Copy link

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.

@easydowork
Copy link

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)

@hugywin
Copy link

hugywin commented Jul 3, 2017

@risacher TypeError: express.basicAuth is not a function

@hassanuos
Copy link

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)

@pak11273
Copy link

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

@tmac12
Copy link

tmac12 commented Feb 2, 2018

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

@Peripona
Copy link

Peripona commented Nov 6, 2018

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.

@yunliang-ding
Copy link

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

good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests