Yii2: wrong bower path alias

Created on 21 Jun 2017  Â·  10Comments  Â·  Source: yiisoft/yii2

What steps will reproduce the problem?

Fresh-installed yii2 base app

What do you get instead?

Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: /home/travkin/my_hosts/united_ua/vendor/bower/jquery/dist

Way to resolve

/vendor/yiisoft/yii2/base/Application.php line 461

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

change to

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

Additional info

| Q | A
| ---------------- | ---
| Yii version | 2.0.12

important need more info bug

Most helpful comment

define aliases in your config if in composer.json you use asset-packagist.org instead of fxp/composer-asset-plugin

'aliases' => [
    '@bower' => '@vendor/bower-asset',
    '@npm'   => '@vendor/npm-asset',
],

All 10 comments

@konorlevich i think you need upgrade your fxp/composer-asset-plugin because installer-paths format is changed, and old version do not understands new format and installs to default bower-asset folder. Try run composer global require fxp/composer-asset-plugin.

define aliases in your config if in composer.json you use asset-packagist.org instead of fxp/composer-asset-plugin

'aliases' => [
    '@bower' => '@vendor/bower-asset',
    '@npm'   => '@vendor/npm-asset',
],

This string Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower'); cann't be changed cause of bc break

I had the same problem with fxp/composer-asset-plugin 1.2. The error disappeared after upgrading the plugin to version 1.3.

In Yii 2.0.12 the config options for the asset-plugin have changed (see), because the old config format was deprecated, and changed in fxp/composer-asset-plugin v1.3.

The section for the asset-plugin has been removed from the install guide in the master branch, and this causes confusion for new installs. This has been discussed at the related commit.

@konorlevich Have you installed application template as it is listed in the manual?

Thanks for posting in our issue tracker.
In order to properly assist you, we need additional information:

  • When does the issue occur?
  • What do you see?
  • What was the expected result?
  • Can you supply us with a stacktrace? (optional)
  • Do you have exact code to reproduce it? Maybe a PHPUnit tests that fails? (optional)

Thanks!

_This is an automated comment, triggered by adding the label status:need more info._

I had same problem, where i want overrides bower, npm, vendor alias.
I set alias on a bootstrap file, but seem yii/base/Application overrides it.
Maybe on setVendorPath method you can add validation is bower, npm, vendor not null.
So use value from Yii::setAlias on bootstrap file.

Thanks.

Or maybe we can use oomphinc/composer-installers-extender globaly for replace fxp/composer-asset-plugin.
And then add :

"extra": { "installer-types": ["bower-asset", "npm-asset"], "installer-paths": { "vendor/bower/{$name}": ["type:bower-asset"], "vendor/npm/{$name}" : ["type:npm-asset"] } },

I solve my problem by doing this.

i think you need upgrade your fxp/composer-asset-plugin because installer-paths format is changed, and old version do not understands new format and installs to default bower-asset folder. Try run composer global require fxp/composer-asset-plugin

@shirase, thank you, it works

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schmunk42 picture schmunk42  Â·  47Comments

spiritdead picture spiritdead  Â·  67Comments

alexandernst picture alexandernst  Â·  163Comments

Faryshta picture Faryshta  Â·  48Comments

rosancoderian picture rosancoderian  Â·  46Comments