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

Cannot require('ws') #989

Closed
vidstige opened this issue Feb 5, 2017 · 4 comments
Closed

Cannot require('ws') #989

vidstige opened this issue Feb 5, 2017 · 4 comments

Comments

@vidstige
Copy link

vidstige commented Feb 5, 2017

I npm installed 2.0.2 and upon just issuing node -e "require('ws')" ws blows up with the following stacktrace.

I'm using node v4.2.6

/Users/vidstige/src/tumel/node_modules/ws/lib/PerMessageDeflate.js:8
const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
                       ^

TypeError: this is not a typed array.
    at Function.from (native)
    at Object.<anonymous> (/Users/vidstige/src/tumel/node_modules/ws/lib/PerMessageDeflate.js:8:24)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/vidstige/src/tumel/node_modules/ws/lib/WebSocket.js:16:27)
    at Module._compile (module.js:410:26)
@lpinca
Copy link
Member

lpinca commented Feb 5, 2017

Buffer.from() does not work on Node.js < 4.5.0. Is it possible for you to upgrade to a more recent version?

@vidstige
Copy link
Author

vidstige commented Feb 5, 2017

Thanks for quick reply. I rather not, using port install nodejs to install which only has 4.3, but might consider later. I could perhaps also downgrade ws?

@vidstige vidstige closed this as completed Feb 5, 2017
@lpinca
Copy link
Member

lpinca commented Feb 5, 2017

Yes, you can use ws@1. It's a shame though as there are a lot of bug fixes in v2. Can I ask why you prefer port over brew? Homebrew has the latest Node.js 4 available at node@4.

$ brew info node@4
node@4: stable 4.7.3 (bottled), HEAD [keg-only]
Platform built on V8 to build network applications
https://nodejs.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/node@4.rb

@vidstige
Copy link
Author

vidstige commented Feb 6, 2017

No, I like ports more. It does have node, but inside another package called node4. But I'll go with that anyway. Thanks fro your help! :)

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

2 participants