哟找不到当地的自耕农发电机

时间:2016-02-29 21:20:35

标签: node.js yeoman yeoman-generator

我创建了一个新的yeoman生成器

'use strict';

var generators = require('yeoman-generator');

module.exports = generators.Base.extend({
  method1: function() {
    this.log('Hello, World!');
  }
});

我的package.json

{
  "name": "generator-mygenerator",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Alexander Zeitler",
  "license": "ISC",
  "dependencies": {
    "yeoman-generator": "^0.22.5"
  }
}

然后我跑了npm link

调用yo mygenerator时出现此错误:

Error mygenerator 

You don't seem to have a generator with the name mygenerator installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 1 registered generators run yo with the `--help` option.

我也试过npm link generator-mygenerator

Node.js版本4.2.3和npm版本3.7.5。 我使用nvm

安装了Node.js.

yo doctor会产生这样的结果:

Yeoman Doctor
Running sanity checks on your system

✔ Global configuration file is valid
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
✔ NODE_PATH matches the npm root

Everything looks all right!

1 个答案:

答案 0 :(得分:0)

index.js必须位于app文件夹中。它改为项目根文件夹。