Aerendir
Aerendir

Reputation: 6399

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

I've just installed Encore to test it and start using it in my projects (great great work!!! Really, thank you!).

I'm immediately having an issue.

When trying to run ./node_modules/.bin/encore dev I receive the exception:

Cannot determine webpack context. (Are you executing webpack from a directory outside of your project?). Try passing the --context option.

I've simply followed the instructions in the official documentation about the first example and the result is this exception.

My project is structured like so:

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

So, basically, I have the classical structure of a Symfony 3.3 project, plus some folders related to JS.

Can anyone help me solve this problem?

This is the very first time I approach a more sophisticated solution to manage css and javascript assets.

Unitl now I've done all putting those files in src/AppBundle/Resources/public/ so I'm not very experienced with this new flow.

Thank you!

Upvotes: 3

Views: 716

Answers (1)

Aerendir
Aerendir

Reputation: 6399

The problem was that I din't run npm init and then npm install.

The library requires a package.json file that is created by npm.

More info here.

Upvotes: 8

Related Questions