简体   繁体   中英

UnexpectedValueException Could not parse version constraint when trying to instal laravelcollective

I am new to laravel and I am trying to install laravelcollective . I am just following to documentation here and I am using this from my project directory:

composer require "laravelcollective/html":"^5.4.0"

Unfortunately, immediately after I press ented I get the following error :

[UnexpectedValueException] Could not parse version constraint :5.4.0: Invalid version string ":5.4.0"

I just don't know how to troubleshoot this. I didn't find much on google and this combined with my lack of experience with laravel leaves me stuck.

Can someone help?

You can add it manually in composer.json then use composer update .

Just add "laravelcollective/html": "5.4.*", under the row with "laravel/framework":"5.4.*",

Like this :

"require": {
        "php": ">=7.0.0",
        "fideloper/proxy": "~3.3",
        "laravel/framework": "5.4.*",
        "laravelcollective/html": "5.4.*", <-- Add this row
        "laravel/tinker": "~1.0"
    },

You should never run composer update without any arguments if you do not want to update all your dependencies.

In your case, the issue probably is that the ^ character is already interpreted by your shell before the argument is passed to Composer. This could possibly be solved by using single quotes instead of double quotes:

composer require 'laravelcollective/html:^5.4.0'

When you used the 5.4.* constraint as suggested in one of the comments above, you added a space after the colon which leads to Composer interpreting the version constraint as a package name. The right command would have been this:

composer require "laravelcollective/html":"5.4.*"
composer require "laravelcollective/html ^5.4.0"

为我工作!

In my case, I was using Laravel 5.7 and kept getting an error when trying to install the Laravel collective.

You can use this command without specifying any version:

composer require 'laravelcollective/html'

It worked for me. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM