Wrong path to bower assets

I just made a fresh install of Yii2 advanced application template.

I got an error when trying to load the front page:

Invalid Parameter – yii\base\InvalidParamException

The file or directory to be published does not exist: /path/to/my/app/appName/vendor/bower/jquery/dist

I looked in the vendor folder and there is no "vendor/bower/jquery/dist" but "vendor/bower-asset/jquery/dist" exists.

I changed the vendor path in yii\base\Application line 461 to:

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

Now it works. What is the disconnect here? Any idea?

I partially understand the cause: I was trying to use asset-packagist. I put the following in composer.json:

"repositories": [


    {


        "type": "composer",


        "url": "https://asset-packagist.org"


    }


]

This caused the assets to be put in the aforementioned directories that did not match the yii path aliases for bower and npm assets.

Perhaps someone could shed some light on how that is supposed to work?

Have same issue.

[s]You don’t have to do anything other than install the Composer asset plugin as described on the Yii 2 installation page :)


composer global require "fxp/composer-asset-plugin:^1.3.1"

[/s]I misunderstood the issue, sorry!

In case you use https://asset-packagist.org you have to define aliases as noted at https://asset-packagist.org/site/about

1 Like

Yes, I found it here github/yii2. Thanks anyway samdark.

I also read that Yii 2.1 will be free from fxp/composer-asset-plugin problems :slight_smile:

1 Like

I too am getting the same problem with no luck.

Can you explain your issue clearly and with all the necessary details, please? :)

From https://asset-packagist.org/site/about:

Yii2 expects Bower and NPM packages to be installed to vendor/bower and vendor/npm folders respectively.

So, to use asset-packagist for Yii2 projects it’s necessary to reassign Bower and NPM aliases in your application config like this:




   $config = [

        ...

        'aliases' => [

            '@bower' => '@vendor/bower-asset',

            '@npm'   => '@vendor/npm-asset',

        ],

        ...

    ];