Yeoman找不到发电机

时间:2017-05-28 07:00:38

标签: node.js yeoman nvm

我正在尝试创建一个yeoman生成器(它已经published on npm),但我遇到了一些障碍。

我不确定这是否与我的节点设置或代码有关。我在几个类似的问题的帮助下解决了问题:

我可以成功运行其他生成器,所以我很确定,此时这是一个代码问题。

生成器与yo一起安装。

$ nvm use 7
Now using node v7.7.4 (npm v4.1.2)
$ npm install -g generator-spike yo
$ ls /Users/developer/.nvm/versions/node/v7.7.4/lib/node_modules
generator-generator generator-spike     http-server     npm         yarn            yo
$ ls /Users/developer/.nvm/versions/node/v7.7.4/lib/node_modules/generator-spike
README.md   actions     app     base.js     node_modules    package.json

Yo安装正确。

$ yo doctor

Yeoman Doctor
Running sanity checks on your system

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

Everything looks all right!

Yeoman找到了发电机。

$ yo --generators
Available Generators:

  generator
    subgenerator
  spike
    actions

但你不能运行发电机:

$ yo spike:actions -f yada
Error spike:actions -f yada 

You don’t seem to have a generator with the name “spike:actions” installed.
But help is on the way:

You can see available generators via npm search yeoman-generator or via http://yeoman.io/generators/. 
Install them with npm install generator-spike:actions.

To see all your installed generators run yo without any arguments. Adding the --help option will also show subgenerators. 

If yo cannot find the generator, run yo doctor to troubleshoot your system.

1 个答案:

答案 0 :(得分:1)

Yeoman不支持ES6 export default。使用module.exports =

从'路径'导入路径; 从' ../ base';

导入Base
module.exports = class Actions extends Base {
  // ...
}