Yii2: new istallation - getting error /vendor/bower/jquery/dist

Created on 25 Jul 2017  路  10Comments  路  Source: yiisoft/yii2

What steps will reproduce the problem?

Installation new istance

What is the expected result?

The file or directory to be published does not exist: /media/sf_Web_share/www/somesite.local/vendor/bower/jquery/dist

What do you get instead?

In my own, I first time see that, but DevOps from my compony always telling me about it for avg 2 month
I shall find the problem, but i don't think i'm enough in this framework, but,.,,,

Additional info

Any server: CentOs/Ubuntu/Debian - detected
PHP: 7,0 or 7.1
Composer: 1.3.1

| Q | A
| ---------------- | ---
| Yii version | 2.0.12
| PHP version | 7.0/7.1
| Operating system | CentOs/Ubuntu/Debian

In fact - there no /vendor/bower/ at all. Only bower-asset folder.

Most helpful comment

What a mess. For whoever else finds this post, if you are upgrading an existing app by overwriting an old composer.json with the latest one (as I did) you need to add aliases to your config/web.php for the following:

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

https://github.com/yiisoft/yii2/issues/14324#issuecomment-311260179

All 10 comments

Global fxp/composer-asset-plugin was old, Sorry!

Close it please

and the solution was... 驴?

@blonder413 the solution is not to use fxp/composer-asset-plugin. Use asset-packagist.org repository instead

I am getting this behavior on a yii2-app-basic template project with a brand-new composer.json and fxp/composer-asset-plugin removed.

{
    "name": "yiisoft/yii2-app-basic",
    "description": "Yii 2 Basic Project Template",
    "keywords": ["yii2", "framework", "basic", "project template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "stable",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "~2.0.14",
        "yiisoft/yii2-bootstrap": "~2.0.0",
        "yiisoft/yii2-swiftmailer": "~2.0.0",
        "influxdb/influxdb-php": "^1.14",
        "yiisoft/yii2-debug": "^2.0"

    },
    "require-dev": {
        "yiisoft/yii2-debug": "~2.0.0",
        "yiisoft/yii2-gii": "~2.0.0",
        "yiisoft/yii2-faker": "~2.0.0",

        "codeception/base": "^2.2.3",
        "codeception/verify": "~0.3.1",
        "codeception/specify": "~0.4.3"
    },
    "config": {
        "process-timeout": 1800,
        "fxp-asset": {
            "enabled": false
        }
    },
    "scripts": {
        "post-install-cmd": [
            "yii\\composer\\Installer::postInstall"
        ],
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject",
            "yii\\composer\\Installer::postInstall"
        ]
    },
    "extra": {
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "runtime": "0777",
                    "web/assets": "0777",
                    "yii": "0755"
                }
            ]
        },
        "yii\\composer\\Installer::postInstall": {
            "generateCookieValidationKey": [
                "config/web.php"
            ]
        }
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ]
}

What a mess. For whoever else finds this post, if you are upgrading an existing app by overwriting an old composer.json with the latest one (as I did) you need to add aliases to your config/web.php for the following:

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

https://github.com/yiisoft/yii2/issues/14324#issuecomment-311260179

I'm surprised that this problem has been coming up reliably for about four years, but every time the issue gets shut (and this must be the 7th thread I've read on the yii issues list alone) and the solution is always to refer to someone else's solution, although the solution is followed by posts suggesting it didn't work. everyone appears very hung up on the difference between 'bower' and 'bower-asset', which I get, but my problem (I know have both directories, aliases, fxp-whatever and asset-packagist blah) but the error still says I'm missing jquery (which I am). How on earth do I get jquery in either of the directories.

I guess to be fair, I now have it working, but with so many solutions having been offered to me, and so many (probably conflicting changes) I'm really sorry but I can't actually say what change I made helped. My best advice would be that it involves

  • updating to the latest fxp thing (no idea how you find out what number it is(or what it does), I just randomly kept going up until it didn't work (1.4.2 was the last one),
  • add the alias suggestion above into the top level of the config array,
  • don't use the "replace" suggestion in one of the other accepted answers,
  • delete the root vendor directory (it never came back, so not sure where it came from in the first place),
  • rename web.php to main.php,
  • enable fxp and asset-packagist,
  • rm your existing vendor directory
  • rm composer.lock,
  • get a GitHub key and
  • download from the worlds slowest download server

chuck in a few apachectl graceful and you might just get there. I was going to attach a composer.json file in case that helped anyone, but apparently GitHub forums don't allow it - really 馃槥

so here it is in text - and please, I'm happy for constructive feedback, but it turned itself into a dogs breakfast:

{
"name": "yiisoft/yii2-app-basic",
"description": "Yii 2 Basic Project Template",
"keywords": ["yii2", "framework", "basic", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "~2.0.14",
"yiisoft/yii2-bootstrap": "~2.0.0",
"yiisoft/yii2-jui": "*",
"aws/aws-sdk-php": "^3.2"
},
"require-dev": {
"yiisoft/yii2-debug": "~2.0.0",
"yiisoft/yii2-gii": "~2.0.0",
"yiisoft/yii2-faker": "~2.0.0"
},
"config": {
"process-timeout": 1800,
"fxp-asset": {
"enabled": true
}
},
"scripts": {
"post-install-cmd": [
"yii\composer\Installer::postInstall"
],
"post-create-project-cmd": [
"yii\composer\Installer::postCreateProject",
"yii\composer\Installer::postInstall"
]
},
"extra": {
"yii\composer\Installer::postCreateProject": {
"setPermission": [
{
"runtime": "0777",
"web/assets": "0777",
"yii": "0755"
}
]
},
"yii\composer\Installer::postInstall": {
"generateCookieValidationKey": [
"config/web.php"
]
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
}

To make it work you needed just asset-packagist.org in repositories section of composer.json

It is the best option until bower-asset dependencies(like jQuery) is removed from Yii core. And core team is already working on it. Seems like yiisoft/yii2 >= 2.1 would be separated from those dependencies. And we'll be able to create REST API`s without pulling all those frontend libraries

Was this page helpful?
0 / 5 - 0 ratings