#StackBounty: #symfony5 #webpack-encore How to fix Command "encore" not found. when trying to add css in symfony?

Bounty: 50

Simply following instructions:

https://symfony.com/doc/current/frontend/encore/installation.html

docker-compose exec php composer require symfony/webpack-encore-bundle
Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
Using version ^1.12 for symfony/webpack-encore-bundle
./composer.json has been updated
Running composer update symfony/webpack-encore-bundle
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking symfony/webpack-encore-bundle (v1.12.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
111 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Run composer recipes at any time to see the status of your Symfony recipes.

Executing script cache:clear [OK]
Executing script assets:install public [OK]

Nothing to unpack


yarn install
yarn install v1.22.11
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 0.04s.

If you are using Symfony Flex, this will install and enable the WebpackEncoreBundle, create the assets/ directory, add a webpack.config.js file, and add node_modules/ to .gitignore. You can skip the rest of this article and go write your first JavaScript and CSS by reading Encore: Setting up your Project!

I have not turned off flex, so it should have install those files, but it did not.
It only added encore bundle to composer.json, updated composer.lock , created .yarn-integrity

{
  "systemParams": "linux-x64-59",
  "modulesFolders": [
    "node_modules"
  ],
  "flags": [],
  "linkedModules": [],
  "topLevelPatterns": [],
  "lockfileEntries": {},
  "files": [],
  "artifacts": {}
}

and yarn.lock:

# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

When I run composer recipes:

docker-compose exec php composer recipes
Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(

                      
 Available recipes.   
                      

 * doctrine/annotations 
 * doctrine/doctrine-bundle 
 * doctrine/doctrine-migrations-bundle 
 * phpunit/phpunit 
 * sensio/framework-extra-bundle 
 * symfony/console 
 * symfony/debug-bundle 
 * symfony/flex 
 * symfony/framework-bundle 
 * symfony/mailer 
 * symfony/maker-bundle 
 * symfony/monolog-bundle 
 * symfony/notifier 
 * symfony/phpunit-bridge 
 * symfony/routing 
 * symfony/security-bundle 
 * symfony/translation 
 * symfony/twig-bundle 
 * symfony/validator 
 * symfony/web-profiler-bundle 
 * symfony/webpack-encore-bundle (recipe not installed)
 * twig/extra-bundle 

Run:
 * composer recipes vendor/package to see details about a recipe.
 * composer recipes:install vendor/package --force -v to update that recipe.

I then run

docker-compose exec php composer recipes:install symfony/webpack-encore-bundle 
Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9003 (fallback through xdebug.client_host/xdebug.client_port) :-(
Run command with -v to see more details


Symfony operations: 1 recipe (795220943d71c24e78b567cea3978461)
  - Configuring symfony/webpack-encore-bundle (>=1.9): From github.com/symfony/recipes:master

Webpack config and various files are installed. But node_modules still only has .yarn-integrity file
.

And running this, I get error:

yarn encore dev
yarn run v1.22.11
error Command "encore" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What am I missing? Or it is a bug in program/documention?

Update

Tried:

 yarn add --dev @symfony/webpack-encore

Getting:

Couldn’t find package "@symfony/stimulus-bridge" on the "npm" registry

Why it even searches on npm registry if I use yarn?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.