Error: webpack-cli tried to access webpack
See original GitHub issueyarn encore dev
crashes with this error:
Error: webpack-cli tried to access webpack (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.
Required package: webpack (via "webpack")
Required by: webpack-cli@virtual:dc3fc578bfa5e06182a4d2be39ede0bc5b74940b1ffe0d70c26892ab140a4699787750fba175dc306292e80b4aa2c8c5f68c2a821e69b2c37e360c0dff36ff66#npm:3.3.11 (via /.../.yarn/$$virtual/webpack-cli-virtual-75e5f04c0a/0/cache/webpack-c
li-npm-3.3.11-f5481479b7-2.zip/node_modules/webpack-cli/bin/utils/)
I’m trying to setup webpack encore in a Symfony 4.4 project which is updated from 3.4. It doesn’t use Flex yet.I followed the steps from the docs (https://symfony.com/doc/3.4/frontend/encore/installation.html)
composer require symfony/webpack-encore-bundle
yarn install
Of course this won’t work, because there is no package.json. So I created a minimalistic package.json.
I also added webpack.config.js and continued:
yarn add @symfony/webpack-encore --dev
yarn encore dev
On the first run it requested to install “webpack-cli” and I confirmed:
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
- webpack-cli (https://github.com/webpack/webpack-cli)
The original webpack full-featured CLI.
We will use "yarn" to install the CLI via "yarn add -D".
Do you want to install 'webpack-cli' (yes/no): yes
Installing 'webpack-cli' (running 'yarn add -D webpack-cli')...
After that and on subsequent runs it crashes with the error above.
Final package.json:
{
"license": "UNLICENSED",
"private": true,
"devDependencies": {
"@symfony/webpack-encore": "^0.28.3",
"webpack-cli": "^3.3.11"
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
After installing webpack and webpack-cli still getting error ...
Try This command Using Npm : npm i -g webpack-cli -D --save.
Read more >Cannot find module 'webpack-cli' error | bobbyhadz
If the error is not resolved, try installing webpack and webpack-cli locally. Open your terminal in your project's root directory (where your package.json...
Read more >Webpack CLI error on reload (watch) - Laracasts
Hi ! Since I update from Vue2 to Vue3 and Laravel Mix v6, I got this error when I run npm run watch...
Read more >Development | webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >[webpack-cli] failed to load | The AI Search Engine You Control
I tried that too, but I think we misunderstood something in the documentation, because I ran into the same error as you. :D...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@fishbone1 Do you also have an issue if you create a
.yarnrc.yml
file with the following content before runningyarn install
?@stof You are right. It works with yarn 1. Maybe we should add a hint in the docs? I didn’t realize that yarn 2 is new and it seems yarn 1 is still mainly used.
@Lyrkan I also tried your suggestion and it worked as well. But effectively it changes yarn to v1 as well. The original (non working)
.yarnrc.yml
looked like this:Thanks for your help!