Search code examples
javascriptjsongeneratoryeomanyeoman-generator

Yeoman generator can't find .yo-rc.json file when installed globally


I have a simple yeoman generator that is all pretty much ready to go. However, it is heavily dependent on the .yo-rc.json file, as I read important configurations from it every time I run the generator.

This works fine if I am running it from the project's directory (by project I mean the generator's project itself), but it won't find it when I am attempting to run it from another project, even with all the steps including npm link.

I feel like I missed something important here, but can't seem to find it in the documentation. Am I supposed to somehow set up a global .yo-rc.json file when my generator is installed globally? Is there a step or configuration I missed?

I doubt this is relevant, but in case it is, this is being developed run on Windows 7.

Thanks!


Solution

  • .yo-rc.json is only used for local project configuration. It is not meant to be used for global configuration.

    For global configuration, you can use the store: true option for each prompts you want to remember with this.prompt().

    The reason behind this is that a user creating a new project doesn't necessarily want his previous choices applied. So the configuration is kept local to a project, so the generator can know the choices user made in the past for the current project; but not globally applied to all the other project they might created.