NodeJS running Git´s project example - node.js

I´m starting studying nodejs to a project, and looking for projects to help me, I found out this one:
https://github.com/kroky/woot
It´s very interesting implementation on Collaborative Rich-Text editor, but, as I´m sayd, I´m starting on it, and I could not run the example from project.
Can anybody explain me how to do this?
I´m already tried to run the file on node folder
node app.js
It failed with:
module.js:338
throw err;
^
Error: Cannot find module 'socket.io'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/celso/derbyjs/examples/woot/woot/node/app.js:3:10)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
Should the project have a package.json with dependencies descriptions?
Thanks for the help!

The error message is very clear: you don't have the module socket.io. Run npm install socket.io to grab it.
If the project has a package.json file (the example you provided doesn't have one, bad practice), then before start, you should run npm install to grab all dependencies.

After cloning any node project first thing to be done is
npm install
and if it still emit error try
npm install "module name from error"
Happy coding!

Related

Cannot find dependency when running krakenjs generator

I have been trying to generate a stub service following the quickstart from the readme for krakenjs However, when I get to the gen step:
$ yo swaggerize
I get the following error:
module.js:327
throw err;
^
Error: Cannot find module '../../lib/util'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/mymac/.nvm/versions/node/v4.4.7/lib/node_modules/generator-swaggerize/generators/app/index.js:5:12)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
No amount of googling seems to find a solution that works for me. I am just trying to PoC several generators for my team.
Any help or guidance would be greatly appreciated.
at Object.<anonymous> (/Users/mymac/.nvm/versions/node/v4.4.7/lib/node_modules/generator-swaggerize/generators/app/index.js:5:12)
I've compared the folder structure of the module on this line with the git repo, and it seems like your version of the module is from the v3.x branch. I could reproduce the error installing the generator-swaggerize#3.0.0-alpha.1 build with npm.
I checked the code in the repo and it seems like the package.json of this branch is misconfigured, so when you npm install it, it doesn't install all the required files for the module to run.
Long story short, you seem to have an early alpha/development version of generator-swaggerize that simply doesn't work.
Not sure how you ended up with that, but you should be able to fix it with installing a stable version.
npm install -g generator-swaggerize#latest
2.0.2 seems to be the latest working version.

How to install: caress server node server.js . Error: 'Cannot find module '....buffertools.node'

I am installing the the library found from MIT students using TUIO. According to their instructions I was supposed to start the server but I got an error.
Does anyone know how to fix this error?
C:\Users\PC\Desktop\server1.1>node examples/server.js
info - socket.io started
module.js:442
throw err;
^
Error: Cannot find module './build/Debug/buffertools.node'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\PC\Desktop\server1.1\node_modules\buffertool
s\buffertools.js:26:20)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
I tried following there steps and got my server stared.
I think you are missing npm i after cloning repo.
please do npm i and try starting server
You need to install the dependency packages before you can run your project.
npm install looks for the packages listed in the package.json file and installs them with their dependencies recursively.
If you are getting specific error in installation of particular package, it could be internet issue/os issue and most probably node and npm version issue. Make sure you are using a stable version of node, its version no should be even.

Getting koa to work (nodejs web framework)

I am running Deepin and trying to get koa to work. There is little documentation on the subject.
I did the following as stated on koajs.com:
$ npm install -g n
$ n 0.11
$ node --harmony my-koa-app.js
I recieve the error:
➜test-koa-app$ sudo node --harmony test-koa-app.js
module.js:338
throw err;
^
Error: Cannot find module 'koa'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/karl/nodejs/test-koa-app/test-koa-app.js:1:73)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
As Mike Kamermans mentioned in the question comments, to use a module in a node application, it must first be installed in the project directory.
To install it, run npm install koa in a terminal in your project folder.
If you've run npm init and setup a package.json file in your project, you can add the --save flag and save a record of the dependency with npm install --save koa.
Version 2 of koa now out. Go here:
https://github.com/koajs/koa

node.js returns "Cannot find module 'lockit-mongodb-adapter'"

I am going through my first node.js project. I've installed lockit , have a app.js file, and when I try to run it I get this error
module.js:340
throw err;
^ Error: Cannot find module 'lockit-mongodb-adapter'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at new module.exports (C:\Users\xx\Documents\mailer\index.js:38:44)
at Object.<anonymous> (C:\Users\xx\Documents\mailer\examples\mongodb\app. js:32:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
I am quite certain I have lockit-mongodb-adapter installed.
You need to install the module. Cd to the root of your app directory and run this command and make sure lockit-mongodb-adapter is in your node modules directory.
npm install lockit-mongodb-adapter
Another thing you can do if you are certain it is installed is double check to see what is installed by running this command:
npm list
And this one to see what is installed globally:
npm list -g
Update:
I was able to reproduce the issue you where having. And to resolve it I deleted the module from the node moules directory. And re-installed with the following command:
npm install lockit-mongodb-adapter -save
It now shows up in npm list with no issues:

Apparently I deleted some of the files on the node_module, how can I restore them?

I was trying to install node trough brew and it was giving a lot of errors, and apparently some file was not giving the permission, so I thunked that the file was from other failed try to intall node and I decide to remove the directory. It failed to remove the dir and the files, but apparently some had been erased.
They are:
module.js:340
throw err;
^
Error: Cannot find module 'child-process-close'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /usr/local/lib/node_modules/npm/lib/npm.js:15:1
at Object. (/usr/local/lib/node_modules/npm/lib/npm.js:461:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
How can I solve this? I just wanted to try sails.js for fun, but I didn't see any fun time yet, only problems.
Thank you
It appears that your issue is not with the sails global or project installation, but rather that you corrupted the nodejs installation. I'd recommend you to just download nodjs again from nodejs.org (this downloads a .pkg) and install it with that package.
If this complains about permissions and overwriting things (which I don't think), try first deleting the whole node_modules folder with sudo:
sudo rm -fr /usr/local/lib/node_modules
I know this is super late. However, I was getting this same error while trying get a react native app up and running.
I installed node with HomeBrew and after getting the following:
Error: Cannot find module 'child-process-close'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at /usr/local/lib/node_modules/npm/lib/npm.js:15:1
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/npm.js:520:3)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
I then ran
brew postinstall node
and got:
Permission denied - /usr/local/lib/node_modules/npm/AUTHORS
So then I ran:
sudo brew postinstall node
and it seemed to work fine. I could go about installing waterline, firebase, or whatever else I tried.
Hope this helps!
Run npm install from your project directory to re-install all modules listed in your package.json.

Resources