我创建了一个新的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
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!
答案 0 :(得分:0)
index.js
必须位于app
文件夹中。它改为项目根文件夹。