首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Angular的Grunt shell任务在VS task Runner Explorer中失败,但在命令提示符下工作

Angular的Grunt shell任务在VS task Runner Explorer中失败,但在命令提示符下工作
EN

Stack Overflow用户
提问于 2017-08-03 22:47:43
回答 1查看 139关注 0票数 1

我有一个用于启动Angular 2构建的grunt脚本。

在命令行上运行grunt成功- Angular构建如预期运行。

在VS 2017中从task Runner Explorer运行任务失败。

Gruntfile.js如下:

代码语言:javascript
复制
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中的输出为:

代码语言:javascript
复制
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.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-04 22:28:49

感谢Mads Kristensen指出他两年前的博客帖子-事实证明VS使用的是与命令提示符不同的工具版本。

https://blogs.msdn.microsoft.com/webdev/2015/03/19/customize-external-web-tools-in-visual-studio-2015/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45487618

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档