grunt htmlcompressor failed 找不到错误 java

grunt htmlcompressor failed Error not found java

在 visual studio 2015 年 运行 grunt task htmlcompressor 时, 任务 returns >> Error: Error: not found: java Warning: htmlcompressor failed to compress html. Use --force to continue. Aborted due to warnings. Process terminated with code 6.

任务代码:

htmlcompressor: {
        compile: {

            files: [{
                expand: true,     // Enable dynamic expansion.
                cwd: 'Scripts/Ng-Views/',      // Src matches are relative to this path.
                src: ['**/*.html'], // Actual pattern(s) to match.
                dest: 'wwwroot/Views/',   // Destination path prefix.
            }],

            options: {
                type: 'html',
                preserveServerScript: true
            }
        }
    },

我认为您可能遇到了 grunt-htmlcompressor 的老问题。

在插件的 GitHub 存储库中有一个 已关闭 问题,其中包括将 PATH 环境更新为 java.exe 的解决方法。请参阅最后一个 post here 了解更多信息。上面写着:

For Windows another workaround will be update "PATH" environment variable buy adding the path to "java.exe", for example: Start> Right click on "Computer"> Properties> Advanced system configuration> Advanced options (tab)> Enviroment vars> Edit PATH and add path to java.exe C: \ Program Files (x86) \ Java \ jre7 \ bin) NOTE: If you have cmd open, close it and open it again, otherwise will not work.