Code Monkey home page Code Monkey logo

Comments (7)

roger2000 avatar roger2000 commented on July 21, 2024

I tried
sudo ./npm install [email protected]

And seems successfully installed, hope this help others. haven't test it with any js at the moment. will update if errors found later.

from websocket-node.

roger2000 avatar roger2000 commented on July 21, 2024

Oh, it seems not able to find the module websocket in JS

./npm list
/home/roger/node-v0.8.8-linux-x64/bin
├─┬ [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
└── [email protected]

module.js:340
throw err;
^
Error: Cannot find module 'websocket'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object. (/home/roger/node-v0.8.8-linux-x64/js/websocketserver.js:2:23)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)

Any help...?

from websocket-node.

roger2000 avatar roger2000 commented on July 21, 2024

I installed in ubuntu12:
/node-v0.8.8-linux-x64/

from websocket-node.

roger2000 avatar roger2000 commented on July 21, 2024

I test it with a single line JS file.

var WebSocketServer = require('websocket').server;

from websocket-node.

roger2000 avatar roger2000 commented on July 21, 2024

case closed, just need to setup NODE_PATH

from websocket-node.

theturtle32 avatar theturtle32 commented on July 21, 2024

This is all because of a combination of two things:
1.) You didn't install node.js in the default system-wide location. That would have made your life much easier. Alternatively, if you don't want it installed system-wide, but still want the convenience of using multiple node versions and keeping them separated, look at using "nvm" to install Node.
2.) From the way you were running the npm command, you weren't using it correctly. You appear to have been running npm from within the directory where node's binaries are installed. That's not right. What you have to understand about node's package manager is that, unlike other package managers such as from python, ruby, and perl, node packages are never installed "system-wide" unless you explicitly pass the "-g" flag to npm. Even then, the majority of them are not designed to be installed system-wide. You run "npm install websocket" from within your individual project directory, and npm will install the module at the current version into that project. You have to install every module you need into every project directory that uses it. That allows you to avoid version conflicts entirely. You can automate the process by creating a "package.json" file in your project directory that lists all its dependencies, and then you can just run "npm install" and it'll recursively install all the module dependencies into the current project directory.

from websocket-node.

roger2000 avatar roger2000 commented on July 21, 2024

Really thank you, that clarify a lot of things for me.

from websocket-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.