Webpack-encore: Clean encore install gives dependency errors

Created on 25 Oct 2018  路  4Comments  路  Source: symfony/webpack-encore

  1. Installed a fresh encore install via:
 composer require symfony/webpack-encore-pack
 yarn install
````

2. Ran ```yarn encore dev``` which gives me the following output: 

PS C:\www\xx> yarn encore dev
yarn run v1.5.1
$ C:\www\xx\node_modules.bin\encore dev
Running webpack ...

ERROR Failed to compile with 52 errors 11:51:33

These dependencies were not found:

  • child_process in ./node_modules/cross-spawn/index.js, ./node_modules/execa/index.js and 1 other
  • fork-ts-checker-webpack-plugin in ./node_modules/@symfony/webpack-encore/lib/plugins/forked-ts-types.js
  • fs in ./node_modules/@symfony/webpack-encore/lib/WebpackConfig.js, ./node_modules/@symfony/webpack-encore/lib/package-helper.js and 37 others
  • module in (webpack)/lib/NormalModule.js, (webpack)/lib/node/NodeTargetPlugin.js
  • net in ./node_modules/growly/lib/gntp.js, ./node_modules/node-notifier/lib/checkGrowl.js
  • readline in ./node_modules/friendly-errors-webpack-plugin/src/output.js
  • spdx-exceptions in ./node_modules/spdx-expression-parse/scan.js
  • spdx-license-ids in ./node_modules/spdx-correct/index.js, ./node_modules/spdx-expression-parse/scan.js
  • spdx-license-ids/deprecated in ./node_modules/spdx-expression-parse/scan.js

To install them, you can run: npm install --save child_process fork-ts-checker-webpack-plugin fs module net readline spdx-exceptions spdx-license-ids spdx-license-ids/deprecated
error An unexpected error occurred: "Command failed.
Exit code: 2
Command: C:\WINDOWS\system32\cmd.exe
Arguments: /d /s /c C:\www\xx\
ode_modules\.bin\encore dev
Directory: C:\www\xx
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "C:\www\xx\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Also, I tried to install the packages manually, the package ```spdx-license-ids/deprecated``` seems to be removed from Github. 

I have tried to add the other packages via:

yarn add child_process fork-ts-checker-webpack-plugin fs module net readline spdx-exceptions spdx-lice
nse-ids

I do see them in the node_modules folder though, the output still suggests that some of the modules (and other modules) are not found.

  • child_process in ./node_modules/cross-spawn/index.js, ./node_modules/execa/index.js and 2 others
  • fs in ./node_modules/@symfony/webpack-encore/lib/WebpackConfig.js, ./node_modules/@symfony/webpack-encore/lib/package-helper.js and 46 others
  • spdx-exceptions in ./node_modules/spdx-expression-parse/scan.js
  • spdx-license-ids in ./node_modules/spdx-correct/index.js, ./node_modules/spdx-expression-parse/scan.js
  • spdx-license-ids/deprecated in ./node_modules/spdx-expression-parse/scan.js
  • tslint in ./node_modules/fork-ts-checker-webpack-plugin/lib/index.js
  • typescript in ./node_modules/fork-ts-checker-webpack-plugin/lib/index.js, ./node_modules/fork-ts-checker-webpack-plugin/lib/CancellationToken.js and 1 other
    ```

Most helpful comment

I had the same issue, and could resolve it by setting the missing dependencies to 'empty' under the 'node' key in the webpack config. But I've managed to resolve it easier by just setting the 'target' to 'node'.

Example:

 // ... setup encore
 const config = Encore.getWebpackConfig();
 config.target = 'node';

 module.exports = config;

Maybe this is a value that should be able to be configurable through Encore itself.

All 4 comments

Wow! This looks a bit nuts. Can anyone else repeat or install cleanly? You might also try deleting your node_modules directory and running yarn install again. I agree - it looks like, for some reason, you're simply missing a bunch of modules! Also, what version of Node and yarn are you running?

Upgraded node to 11
Upgraded yarn 1.10.1
Removed node_modules, did change anything

I had the same issue, and could resolve it by setting the missing dependencies to 'empty' under the 'node' key in the webpack config. But I've managed to resolve it easier by just setting the 'target' to 'node'.

Example:

 // ... setup encore
 const config = Encore.getWebpackConfig();
 config.target = 'node';

 module.exports = config;

Maybe this is a value that should be able to be configurable through Encore itself.

Yeah, I am seeing this as well and not having much luck in fixing it.

I have tried both npm and yarn and I still see the same problem. Removed node_modules and package-lock.json/yarn.lock a few times but still seeing the issue.

Using Ubuntu 14.04.6 LTS, Node v10.14.0, NPM v6.4.1, Yarn 1.16.0. I was on a older version of Node and NPM but after upgrading still has the same issue.

Going to keep on trying to see if I can get to the bottom of what is going on.

UPDATE:
Ok, finally got to the bottom of this and I was being a numpty. I had my app.js file have the contents of webpack.config.js which obviously caused some issues.

Was this page helpful?
0 / 5 - 0 ratings