Symfony Encore: Cannot define webpack context. (Are you running webpack from a directory outside of your project?)

I just installed Encore to test it and start using it in my projects (great job !!! Indeed, thanks!).

I immediately have a problem.

./node_modules/.bin/encore dev

I get an exception when trying to run :

Unable to define webpack context. (Are you running webpack from a directory outside of your project?). Try passing the --context parameter.

I just followed the instructions in the official documentation for the first example and the result is this exception.

My project is structured like this:

my-app-root-folder
- app
- bin
- nome_modules
- src
- tests
- var
- vendor
- web
...
composer.json
composer.lock
webpack.config.js

      

So basically I have a classic Symfony 3.3 project structure as well as a couple of folders related to JS

.

Can anyone help me solve this problem?

This is the first time I come across a more complex css and javascript resource management solution.

Unitl now I have made all these files in src/AppBundle/Resources/public/

, so I am not very good with this new thread.

Thank!

+3


source to share


1 answer


The problem was that I don't start npm init

and then npm install

.

The library requires a file package.json

generated by npm.



More details here .

+6


source







All Articles