Question

I created a yeoman generator - generator-ngbp and published it to npm. You can install it via

npm install -g generator-ngbp

While working locally via npm link, everything worked well, including the "module" subgenerator

yo ngbp:module "moduleName"

When I deleted the linked node_modules folder under nodejs and installed it as described above from npm, the node_modules folder for generator-ngbp did not contain the "module" folder, which houses the subgenerator, and the "module" subgenerator doesn't work.

Can anyone see what I'm doing wrong? Does it have something to do with the npm publish?

Was it helpful?

Solution

Ok, I found the answer to this. Apparently, the Yeoman generator-generator added a "files" option to my package.json when I first generated my generator (that's a mouthful).

It looked like this...

"files":[
    "app"
],

This tells npm exactly which files to include, which seems kinda dumb, since it leads you down a path to failure. If you follow the official Yeoman tutorial further and create your own subgenerator, it will not get published, due to this unfortunate config setting.

Just delete this json property completely and all the files in your generator will get published to npm when you "npm publish" (you need to increment your "version" in package.json to publish again though).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top