1

I'm having issues installing Bower components using my Gruntfile.js. I can however install the Bower components fine using Bower command.

Installing Bower components using Bower command works fine.

bower install

I cannot however install Bower components using Grunt command

grunt bower:install

Hers's some details.

bower.json:

{
    "name": "test",
    "version": "0.0.2",
    "dependencies": {
        "angular": "latest",
        "bootstrap": "latest",
        "lodash": "latest",
        "font-awesome": "latest"
    },
    "devDependencies": {
        "angular-mocks": "latest"
    }
}

.bowerrc:

{
    "directory": "libs",
    "json": "bower.json"
}

Gruntfile.js:

bower: {
    install: {
        options: {
            install: true,
            copy: false,
            targetDir: './libs'
        }
    }
}

When I try to install Bower components using Grunt, I get the following errors:

Running "bower:install" (bower) task
...
bower validate 1.3.15 against git://github.com/angular/bower-angular.git#*
bower new version for git://github.com/angular/bower-angular.git#*
bower resolve git://github.com/angular/bower-angular.git#*
Fatal error: Arguments to path.join must be strings

Does anyone see what is wrong with my Gruntfile.js file and why I get this error when installing Bower components using Grunt? Thanks.

2
  • Would updating your bower version help? Or are you on the latest?
    – mrjoelkemp
    Nov 7, 2015 at 2:00
  • I'm using grunt-cli v0.1.13 and grunt v0.4.5. I think that is the latest version.
    – Lydon
    Nov 7, 2015 at 2:08

1 Answer 1

1

Here's how I have my configuration which is working for me:

bower: {
            install: {
                options: {
                    targetDir: bowerDir,
                    install: true,
                    cleanTargetDir: false,
                    cleanBowerDir: false,
                    bowerOptions: {}
                }
            }
        }

Also make sure you have the dependencies in your package.json file:

  "devDependencies": {
    "bower": "^1.3.1",
    "grunt": "^0.4.5",
    "grunt-bower-task": "^0.4.0",
    "grunt-cli": "^0.1.13",

also try running these commands:

npm install grunt-cli --save-dev
npm install grunt-bower-task --save-dev
6
  • Your configuration looks very similar to mine. Copying your config didn't fix it. I also have devDependencies in my package.json file.
    – Lydon
    Nov 7, 2015 at 2:13
  • what's your bower version ? Can you post your bower.json file ?
    – guilhebl
    Nov 7, 2015 at 5:15
  • bower is v1.6.5. I"ve posted my bower.json file above.
    – Lydon
    Nov 8, 2015 at 2:11
  • also try running these commands: npm install grunt-cli --save-dev npm install grunt-bower-task --save-dev
    – guilhebl
    Nov 9, 2015 at 2:00
  • I'm not exactly sure how your suggestion fixed the issue, but it has. Can you explain why you suggested using: npm install grunt-cli --save-dev npm install grunt-bower-task --save-dev and how this solved the problem?
    – Lydon
    Nov 10, 2015 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.