我正在为我的网站使用grunt.js构建脚本。基本的站点结构是
www/
    homepage_and_other_stuff/
    hexo_blog/
        hexo_stuff/
        package.json
        node_modules/
    node_modules/
    Gruntfile.js
    package.json我正在使用grunt exec来清理和生成我的Hexo站点。相关代码如下:
module.exports = function(grunt) {
    // Project config
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        // CLEAN and GENERATE the blog portion of the site
        exec: {
            cd_blog: "cd blog",
            clean_blog: "hexo clean",
            generate_blog: "hexo generate",
            go_back: "cd ../"
        }
    });
    // Tasks
    grunt.loadNpmTasks("grunt-exec");
    // Build
    grunt.registerTask("build", "Builds site for production", function() {
        grunt.log.writeln("Building site..."["blue"]);
        grunt.task.run("exec");
    });
};但是,当通过grunt-exec运行'hexo clean‘时,我得到了响应:
Usage: hexo <command>
Commands: 
  help     Get help on a command. 
  init     Create a new Hexo folder.
  version  Display version information.
Global Options:
  --config  Specify config file instead of using _config.yml
  --cwd     Specify the CWD
  --debug   Display all verbose messages in the terminal
  --draft   Display draft posts
  --safe    Disable all plugins and scripts
  --silent  Hide output on console
For more help, you can use 'hexo help [command]' for the detailed information
or you can check the docs: http://hexo.io/docs/因为它认为我没有在我的Hexo命令中添加clean或generate参数。
我认为Hexo安装在/blog/的node_modules中,而不是Grunt的node_modules安装在根目录中,这是有问题的,然而,我在根目录中尝试了npm install hexo --save-dev,但在运行grunt-build时仍然得到相同的错误
发布于 2019-08-08 02:19:07
我最终使用了grunt-hexo。我认为Grunt只是与多个package.json之类的东西发生了冲突。
https://stackoverflow.com/questions/57397107
复制相似问题