我正在尝试按照Yeoman文档中描述的那样在Yeoman中加载“generator-jhipster”:
http://yeoman.io/authoring/integrating-yeoman.html
var yeoman = require('yeoman-environment');
env.register(require.resolve('generator-jhipster'), 'jhipster:app');
“generator-jhipster”和“generator-jhipster-entity-audit”模块安装在节点和应用程序中,事实上,我可以使用“yo”命令中的“generator-jhipster”而没有问题,但是当我运行我的节点脚本时,它会给我错误:
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)
有关如何解决此错误的任何想法?
答案 0 :(得分:3)
解决。
jHipster genetator在主文件夹上没有index.js,因此,调用它的正确代码是:
var yeoman = require('yeoman-environment');
var env = yeoman.createEnv();
env.register(require.resolve('generator-jhipster/generators/app'), 'jhipster:app');