Search code examples
node.jsyokraken.js

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.


Solution

  • 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 [email protected] 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.