简体   繁体   中英

Cannot find module 'generator-jhipster'

I am trying to load the "generator-jhipster' inside Yeoman as is described on the Yeoman documentation:

http://yeoman.io/authoring/integrating-yeoman.html

var yeoman = require('yeoman-environment');
env.register(require.resolve('generator-jhipster'), 'jhipster:app');

The "generator-jhipster' and "generator-jhipster-entity-audit" modules are installed in node and in the app, in fact, I can use the "generator-jhipster" from the "yo "command without problems, but when I run my node Script, it give me the error:

module.js:549
    throw err;
    ^

Error: Cannot find module 'generator-jhipster'
    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:\DANI\Randoop\JHIPSTER\server.js:6:16)
    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)

Any idea about how to solve this error?

Solved.

The jHipster genetator don't have the index.js on the main folder, so, the correct code to invoke it is:

var yeoman = require('yeoman-environment');
var env = yeoman.createEnv();
env.register(require.resolve('generator-jhipster/generators/app'), 'jhipster:app');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM