Cannot find dependency when running krakenjs generator - node.js

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.

Related

NPM dead after update - cannot find module (OSX)

Just did a minor npm update to the latest version (I can't remember what it was as npm no longer works - hence the question) but I think my installed version before the update was 5.6.0. That could be wrong though.
Anyway after running...
sudo npm install -g npm
... npm no longer works at all. Anything I do results in :
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module './auth.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:7:17)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
Any suggestions?
After trying a few different things including reinstalling node via brew the only thing that worked was to download and run the node installer binary from the node site.
Hope it helps somebody else.
I fixed this issue this way:
yarn global add npm

NodeJS: Error: Cannot find module 'ytdl-core'

I was creating a discord music bot in NodeJS, with discord.js as well, but whenever I run it, I get this error: (the file is not named module.js)
module.js:549
throw err;
^
Error: Cannot find module 'ytdl-core'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module.__load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\Matthew\Desktop\discord bot\bot.js:2:12)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
At first, I thought it was because I needed to npm install the module like I did with discord.js, but instead I got the same error.
You require but don't install ytdl-core.
Please install it with command :
npm install ytdl-core
or install with yarn:
yarn add ytdl-core
As you mentioned that you have already done npm install ytdl-core and still you got an error.
Please make sure ytdl-core is installed.
Log suggests that bot.js require ytdl-core. So, please make sure that you have
var ytdlCore = require("ytdl-core");
May this help you. Or please add more code so I can distinguish error.

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.

NodeJS running Git´s project example

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!

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