composer需要[package]结果[Composer \ Downloader \ TransportException] Content-Length不匹配

I am trying to run composer require laravel/passport=~1.0 but each time it results in the following errors:

composer require laravel/passport=~1.0
./composer.json has been updated
Loading composer repositories with package information

The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Operation timed out
Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Operation timed out
https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Updating dependencies (including require-dev)

Installation failed, reverting ./composer.json to its original content.


  [Composer\Downloader\TransportException]
  Content-Length mismatch


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

Following this thread I then tried adding this to the bottom of composer.json

"config": {
    "github-protocols": [
      "https"
    ]
  },
  "repositories": {
    "packagist": {
      "type": "composer",
      "url": "https://packagist.org"
    }
  }

but still getting the same error. I am no expert in terminal or composer but this happened all of a sudden and I don't think I did anything different that would cause this issue. Had no problem previously when installing other packages.

php
dongyuji7309
dongyuji7309 这是相同的错误消息。我重新启动并再次尝试了getcomposer.org/doc/articles/troubleshooting.md#degraded-mode中的步骤,它允许我运行命令并立即安装包,谢谢!
3 年多之前 回复
dop82210
dop82210 嗯,我上面列出的命令在我的机器上运行正常。它至少会给你同样的错误,或者新的东西吗?可能是因为互联网连接不良,防火墙问题或DNS问题。您是否尝试过该错误提及的页面中列出的任何修复程序?您还可以尝试将“laravel/password”:“~1.0”添加到composer.json文件的require部分,然后在命令行上运行composerinstall。作曲家需要命令本质上是一个捷径。但是,如果您遇到连接问题,则会遇到同样的问题。
3 年多之前 回复
dshp9580656
dshp9580656 很不幸的是,不行
3 年多之前 回复
dougongnan2167
dougongnan2167 用这个命令好运:composer需要laravel/passport:~1.0?
3 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问