4

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?

Update 2

Did you not install yarn through npm package manager? If not I recommend you do that. npm install --global yarn

I can't remember how did I install yarn and I do not know how to check. Tried:

npm install --global yarn

> [email protected] preinstall /home/darius/.nvm/versions/node/v9.11.2/lib/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)

/home/darius/.nvm/versions/node/v9.11.2/bin/yarn -> /home/darius/.nvm/versions/node/v9.11.2/lib/node_modules/yarn/bin/yarn.js
/home/darius/.nvm/versions/node/v9.11.2/bin/yarnpkg -> /home/darius/.nvm/versions/node/v9.11.2/lib/node_modules/yarn/bin/yarn.js
+ [email protected]
updated 1 package in 0.497s

Then again

yarn add --dev @symfony/webpack-encore
yarn add v1.22.11
[1/4] Resolving packages...
⠄ @symfony/stimulus-bridge@^2.0.0
error Couldn't find package "@symfony/stimulus-bridge" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Update 3

Yes, I am mixing commands - some run from docker, some from host machine. Yarn I run from host because I do not know yet how to install on docker, I have tried, but no success. Is that bad that I use yarn, npm from host?

And volumes information you can see in docker-compose.yml:

version: "3"
services:
    php:
        build: docker/php
        volumes:
            - .:/app:cached

            # for xdebug
            - ./docker/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
#            - ./docker/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini
            # end for xdebug
        working_dir: /app
        container_name: margin_php
        depends_on:
            - mysql

    nginx:
        image: nginx:1.15.0
        ports:
            - 127.0.0.1:${NGINX_PORT}:80
        volumes:
            - .:/app:cached
            - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:cached
        container_name: margin_nginx
        depends_on:
            - php

    mysql:
        image: mysql:8.0
        volumes:
            - ./docker/mysql/data:/var/lib/mysql
        ports:
            - 127.0.0.1:${MYSQL_PORT}:3306
        environment:
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
            MYSQL_DB_NAME: ${MYSQL_DB_NAME}
        container_name: margin_mysql
2
  • 1
    Try running yarn add --dev @symfony/webpack-encore Commented Aug 29, 2021 at 7:14
  • Did you not install yarn through npm package manager? If not I recommend you do that. npm install --global yarn. Commented Aug 29, 2021 at 7:36

1 Answer 1

1

try this command yarn add --dev @symfony/webpack-encore –

also install yarn from the npm package manager. npm install --global yarn

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.