创buildYeoman发电机的问题

我已经尝试了两种不同的方法来创buildYeoman生成器,并且都失败了。 这是我现在在哪里,但首先有几个笔记:

  • yo doctor通过所有testing
  • 我已经通过更改默认的安装path修复了npm的权限, 详见这里 。

尝试1:我安装了发电机组发电机模块没有错误,但执行yo generator导致以下错误:

 module.js:328 throw err; ^ Error: Cannot find module 'download' at Function.Module._resolveFilename (module.js:326:15) at Function.Module._load (module.js:277:25) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at Object.<anonymous> (/usr/local/lib/node_modules/generator-generator/node_modules/yeoman-generator/lib/actions/fetch.js:3:16) at Module._compile (module.js:398:26) at Object.Module._extensions..js (module.js:405:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Module.require (module.js:354:17) 

我猜测并运行npm install -g download ,但是这并没有解决任何问题。

尝试2我遵循Yeoman的创作页面上列出的步骤,但即使npm link导致有效的path到我的新发电机, yo boilerplate只是导致发电机没有安装错误。 生成器文件结构如下:

 generator-boilerplate app index.js .yo-rc.json package.json 

package.json的内容是:

 { "name": "generator-boilerplate", "version": "0.1.0", "description": "A Yeoman generator for a standard front-end project", "files": [ "app" ], "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ "yeoman-generator", "boilerplate" ], "author": "<my name>", "license": "UNLICENSED", "private": true, "dependencies": { "yeoman-generator": "^0.22.3" } } 

app / index.js的内容是(只是为了得到一些工作):

 'use strict'; var util = require('util'); var path = require('path'); var generators = require('yeoman-generator'); var chalk = require('chalk'); var Boilerplate = generators.Base.extend({ // The name `constructor` is important here constructor: function () { // Calling the super constructor is important so our generator is correctly set up generators.Base.apply(this, arguments); // Next, add your custom code this.option('coffee'); // This method adds support for a `--coffee` flag }, promptUser: function() { var done = this.async(); // have Yeoman greet the user console.log(this.yeoman); var prompts = [{ name: 'appName', message: 'What is your app\'s name ?' },{ type: 'confirm', name: 'addDemoSection', message: 'Would you like to generate a demo section ?', default: true }]; this.prompt(prompts, function (props) { this.appName = props.appName; this.addDemoSection = props.addDemoSection; done(); }.bind(this)); } }); module.exports = Boilerplate; 

任何帮助将不胜感激。 谢谢!

错误1:这是不幸的一个NPM错误。 你应该更新npm到最新版本,卸载并重新安装。 这些错误发生在npm 2和3之间。

错误2:确保你在最新的哟。 然后你可以运行DEBUG=* yo boilerplate ,这会给你更多的信息,以确定Yeoman在哪里search注册生成器,也可能是为什么它没有find你的链接本地生成器。