Reputation: 2327
I am currently stuck at the Encore/Webpack installation. I followed the steps at symfony.com. But when continuing to the simple example I got stuck at running yarn encore dev
. I get the error: "Command "encore" not found". I also have an error when running symfony server:start
after installing Encore and navigating to a view:
An exception has been thrown during the rendering of a template ("Could not find the entrypoints file from Webpack: the file "path/entrypoints.json" does not exist.").
As far as I know the entrypoints.json should have been autogenerated. I have Yarn 1.22.10 and NodeJS 14.16.1.
I executed the commands composer require symfony/webpack-encore-bundle
and yarn install
composer require webpack
encore dev
is supposed to be living. I watched a YouTube video and followed it (https://youtu.be/Fs_4FMoSO90). That's why I know this. I wonder why I don't have it. Below is the package.json from the video. My package.json only has the dev dependency Bootstrap.npm install
Package.json from video:
{
"devDependencies": {
"@symfony/webpack-encore": "^0.31.0",
"core-js": "^3.0.0",
"regenerator-runtime": "^0.13.2",
"webpack-notifier": "^1.6.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
}
}
My package.json:
{
"devDependencies": {
"bootstrap": "^5.0.0"
}
}
I removed the package.json, package-lock.json and executed yarn install
again and it installed some packages. I didn't need NPM. I already got Bootstrap from my Yarn.lock (that's the only thing in there). I still have both errors though.
After Yivi's advice I executed composer req webpack
, yarn install
and yarn encore dev
. The difference is that I executed composer require symfony/webpack-encore-bundle
which is what is mentioned on the installation page on the symfony website. The yarn encore dev
command tries to run webpack now, but I get the following error: Error: Encore.enableStimulusBridge is not a recognized property or method. webpack.config.js:26 Object.<anonymous>
webpack.config.js line 26
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
.enableStimulusBridge('./assets/controllers.json')
Upvotes: 2
Views: 8857
Reputation: 2327
Your advice worked msg. I installed the recipes with composer recipes:install symfony/webpack-encore-bundle --force -v
and now yarn encore dev
compiles webpack successfully. I now also know that I accidentally kept the package.json from the video in my project which explains why my error changed from Command encore not found
to Error: Encore.enableStimulusBridge is not a recognized property or method. webpack.config.js:26 Object.<anonymous>
Upvotes: 3