相关疑难解决方法(0)

使用grunt自动执行npm和bower安装

我有一个节点/角度项目,它使用npm进行后端依赖管理,并使用bower进行前端依赖管理.我想使用grunt任务来执行两个安装命令.我一直无法弄清楚如何做到这一点.

我尝试使用exec,但实际上并没有安装任何东西.

module.exports = function(grunt) {

    grunt.registerTask('install', 'install the backend and frontend dependencies', function() {
        // adapted from http://www.dzone.com/snippets/execute-unix-command-nodejs
        var exec = require('child_process').exec,
            sys  = require('sys');

        function puts(error, stdout, stderr) { console.log(stdout); sys.puts(stdout) }

        // assuming this command is run from the root of the repo
        exec('bower install', {cwd: './frontend'}, puts);
    });

};
Run Code Online (Sandbox Code Playgroud)

当我cd进入前端,打开node,并从控制台运行此代码,这工作正常.我在咕噜咕噜的任务中做错了什么?

(我也尝试使用bower和npm API,但也无法使用.)

javascript node.js npm gruntjs bower

63
推荐指数
3
解决办法
3万
查看次数

标签 统计

bower ×1

gruntjs ×1

javascript ×1

node.js ×1

npm ×1