我有一个奇怪的问题。 我使用Symfony Flex,并且从事现有项目。我尝试使用以下命令安装webpack-encore-bundle:
composer require symfony/webpack-encore-bundle
然后我得到了:
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.2.*"
Package operations: 1 install, 0 updates, 0 removals
- Installing symfony/webpack-encore-bundle (v1.6.2): Loading from cache
Package symfony/webpack-encore-pack is abandoned, you should avoid using it. Use symfony/webpack-encore-bundle instead.
Writing lock file
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (8e557491367cda509fceebb187833635)
- Configuring symfony/webpack-encore-bundle (>=1.0): From github.com/symfony/recipes:master
Executing script cache:clear [OK]
Executing script assets:install --symlink --relative public [OK]
Some files may have been created or updated to configure your new packages.
Please review, edit and commit them: these files are yours.
然后我跑:
yarn install
我明白了:
yarn install v1.16.0
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > sass-loader@7.1.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 2.39s.
一切似乎都很好。现在我刷新了项目,我得到了:
ClassNotFoundException
Attempted to load class "WebpackEncoreBundle" from namespace "Symfony\WebpackEncoreBundle".
Did you forget a "use" statement for another namespace?
这是我在bundles.php中拥有的东西:
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
在composer.json中,我有:
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
我跑步:
yarn encore dev
它编译成功,但是我有同样的错误。
我也尝试了以下命令:
composer remove symfony/webpack-encore-bundle
然后我再试一次
composer require symfony/webpack-encore-bundle
然后我们遇到了同样的错误,这个循环永远不会结束。
答案 0 :(得分:0)
我有此错误,我只是通过安装webpack-encore-bundle
来解决它:
composer require symfony/webpack-encore-bundle
就我而言,我还必须在doctrine-orm-admin-bundle
之前安装webpack-encore-bundle
:
composer require sonata-project/doctrine-orm-admin-bundle
答案 1 :(得分:0)
您是否使用 Vagrant(例如通过 Laravel Homestead)或任何其他类似工具? 我发现在这种情况下,它是一个没有同步到现有框的文件夹。
可能遇到的问题:
这在这里似乎有点偏离主题,但我自己在这个问题上花了大约 2 天的时间,但我没有找到针对这个特定问题组合的任何答案。 这就是为什么我要与您深入分享的原因。
让我们假设代码在一个盒子中运行并同步到它,这里是如何最终检查和修复这个特定的场景和依赖。
\r
vagrant halt
或 composer install
composer update
是否不排除要同步的 Homestead.yaml
文件夹 (?)vendor
vagrant up --provision
是否存在您可以为此使用任何其他技术堆栈 - 不同步背后的基本问题在任何地方都应该是相似的。 例如,在 Docker 中,这可能是缓存问题,具体取决于您的设置。
假设您将 Laravel Homestead 与 Vagrant 与“rsync”文件夹更新一起使用,那么您可能希望包含“vendor”文件夹 (请注意,这会消耗同步性能)。此设置适用于 Mac,但任何其他同步方法都应该类似。
我不能 100% 确定重新配置是否需要这样做,但就我而言,它似乎可以解决问题。
vendor/symfony/webpack-encore-bundle