Socket.io: module can not be found

2

I was playing with Socket.io, everything working fine, when I gave the command node app.js from one time to another NodeJS returns me an error (it was working before)

  

Can not find module 'socket.io'

I looked for another example on the internet colei and it always tells me the same thing. But when I enter the node through cmd and execute var foo = require('socket.io'); it finds the module without any problem.

    
asked by anonymous 07.01.2016 / 16:33

1 answer

2

Try to install the package, in the app.js file directory, type npm install socket.io

NPM is a NodeJS package manager, so using it is simple. First create the manifest of your application with the command npm init , it will ask you some questions and will generate the file package.json where it will be stored among other things, the dependencies of your application.

Dependencies installed with the npm install command are saved to the node_modules directory within your project. If you add the save ( npm install --save pacote ) option the dependency is permanently saved in the manifest.

To install all the dependencies of a package using the manifest, simply run the command npm install in the directory of your application.

    
07.01.2016 / 16:45