我有一个使用npm管理后端依赖和bower管理前端依赖的node/angular项目。我想使用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
的?是以相同的方式吗?还是有其他方法? - xavier.seignard