我有一个用于启动 Angular 2 构建的 grunt 脚本。
在命令行上运行grunt
成功 - Angular 构建按预期运行。
在 VS 2017 中从 Task Runner Explorer 运行任务失败。
Gruntfile.js 如下:
module.exports = function (grunt) {
grunt.initConfig({
shell: {
options: {
stderr: false
},
angularBuild: {
command: 'ng build --prod'
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', ['shell']);
};
Task Runner Explorer 中的输出为:
D:\Work> cmd.exe /c grunt -b "D:\Work" --gruntfile "D:\Work\Gruntfile.js" default --color
Running "shell:angularBuild" (shell) task
Warning: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "ng build --prod"
D:\Work\node_modules\@angular\cli\models\config\config.js:17
constructor(_configPath, schema, configJson, fallbacks = []) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\Work\node_modules\@angular\cli\models\config.js:3:18)
at Module._compile (module.js:397:26)
at Object.Module._extensions..js (module.js:404:10)
Use --force to continue.
Aborted due to warnings.
Process terminated with code 6.