Bower folder is not found in vendor folder in yii2 basic application

11,148

Solution 1

To manage bower and npm package dependencies through Composer, you need to install (globally) fxp/composer-asset-plugin :

composer global require "fxp/composer-asset-plugin:~1.1.1"
composer install

Read more : http://www.yiiframework.com/doc-2.0/guide-start-installation.html#installing-via-composer

Solution 2

first download the default dependencies

composer global require "fxp/composer-asset-plugin:~1.0.3"

then just run

composer install

then reload your site.

Solution 3

Goto /vendor/yiisoft/yii2/base/Application.php.

Goto line 456.

Change

Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower');

to

Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower' . DIRECTORY_SEPARATOR . 'bower-asset');

Solution 4

This may break something later but this was much quicker than trying to root out the composer issue. I tried that too to no avail. I just deciced to give it what it was asking for.

If someone knows why this workaround is not good, please speak up.

Goto /vendor/yiisoft/yii2/base/Application.php.

    public function setVendorPath($path)
{
    $this->_vendorPath = Yii::getAlias($path);
    Yii::setAlias('@vendor', $this->_vendorPath);
    Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower-asset'); //it was just 'bower'
    Yii::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm');
}
Share:
11,148
Ankita
Author by

Ankita

I am a Mobile and web application developer. I love to work with JavaScript. I believe in working with upcoming new technologies and languages.

Updated on June 11, 2022

Comments

  • Ankita
    Ankita almost 2 years

    I had downloaded a basic yii2 application.And then pushed into git.But then in other pc I installed all the dependencies using a composer. But I dont have bower folder now so getting error:

    The file or directory to be published does not exist: C:\xampp\htdocs\jumpbyte-site\vendor\bower/jquery/dist'

    My composer.json file has following require dependencies:

    "require": {
            "php": ">=5.4.0",
            "yiisoft/yii2": "*",
            "yiisoft/yii2-bootstrap": "*",
            "yiisoft/yii2-swiftmailer": "*",
            "himiklab/yii2-sitemap-module": "*"
        },