【发布时间】:2012-12-19 10:47:02
【问题描述】:
我有一个节点/角度项目,它使用 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);
});
};
当我 cd 进入前端时,打开 node,并从控制台运行此代码,这工作正常。我在 grunt 任务中做错了什么?
(我也尝试使用 bower 和 npm API,但也无法使用。)
【问题讨论】:
-
我的配置相同,想知道你是如何运行
npm install的?以同样的方式?还是有其他方法?
标签: javascript node.js npm bower gruntjs