Note that you can get this error if you installed the NPM module globally (with the -g option) and did not tell node use the global module path to resolve the requirements.
On Linux, I installed the websocket module globally:
$ sudo npm install -g websocket npm http GET https://registry.npmjs.org/websocket npm http 200 https://registry.npmjs.org/websocket npm http GET https://registry.npmjs.org/websocket/-/websocket-1.0.8.tgz npm http 200 https://registry.npmjs.org/websocket/-/websocket-1.0.8.tgz > websocket@1.0.8 install /usr/local/lib/node_modules/websocket > node install.js [websocket v1.0.8] Attempting to compile native extensions. [websocket v1.0.8] Native extension compilation successful! websocket@1.0.8 /usr/local/lib/node_modules/websocket
After that, I had to export the NODE_PATH environment variable to point to the path specified in the above output:
export NODE_PATH=/usr/local/lib/node_modules
After that:
$ node > require('websocket') { server: { [Function: WebSocketServer] super_: { [Function: EventEmitter] listenerCount: [Function] } }, ...
Hope this helps someone find this error message.
Drew noakes
source share