Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9114185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:08:36+00:00 2026-06-17T04:08:36+00:00

I have a node / angular project that uses npm for backend dependency management

  • 0

I have a node / angular project that uses npm for backend dependency management and bower for frontend dependency management. I’d like to use a grunt task to do both install commands. I haven’t been able to figure out how to do it.

I made an attempt using exec, but it doesn’t actually install anything.

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);
    });

};

When I cd into frontend, open up node, and run this code from the console, this works fine. What am I doing wrong in the grunt task?

(I also tried to use the bower and npm APIs, but couldn’t make that work either.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:08:37+00:00Added an answer on June 17, 2026 at 4:08 am

    You need to tell grunt that you’re using an async method (.exec) by calling the this.async() method, getting a callback, and calling that when exec is done.

    This should work:

    module.exports = function(grunt) {
        grunt.registerTask('install', 'install the backend and frontend dependencies', function() {
            var exec = require('child_process').exec;
            var cb = this.async();
            exec('bower install', {cwd: './frontend'}, function(err, stdout, stderr) {
                console.log(stdout);
                cb();
            });
        });
    };
    

    See Why doesn’t my asynchronous task complete?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a node app that has a string of require s, like this:
I have a node type (reviews) that uses CCK to refer to another kind
We have a node.js app that uses node_msyql , a great little library for
I have a node.js server running on ec2. I'd like for that server to
Let me explain best with an example. Say you have node class that can
I have a node.js (v0.6.12) application that starts by evaluating a Javascript file, startup.js.
I have a node application that is not a web application - it completes
I have a Node.JS server that works fine on localhost . Now I want
I currently have node.js version 0.8.8, and npm 1.1.59 installed. Whenever I run: $
Have installed Node version manager 'n'. Installed 'mocha' using n npm 0.6.4 install mocha

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.