Webpack-encore: Cannot find module 'babel-preset-env' on fresh install of webpack-encore

Created on 8 Nov 2018  路  2Comments  路  Source: symfony/webpack-encore

I've done a fresh install of a project, installed all composer dependencies with composer install.
Issued the command: yarn add @symfony/webpack-encore --dev
Setup webpack.config.js with the encore documentation as an example
Ran the command: ./node_modules/.bin/encore dev

And got the following errors:
/node_modules/@babel/core/lib/config/files/plugins.js:152
throw e;
^

Error: Cannot find module 'babel-preset-env' from '/home/user/git/project'

  • Did you mean "@babel/env"?
    at Function.module.exports [as sync] (/home/user/git/project/node_modules/resolve/lib/sync.js:43:15)

Tried installing babel-preset-env via yarn and ran encore dev command again, and got a failed to compile with 1 error message:

Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: Cannot read property 'bindings' of null

Most helpful comment

Hey @galens!

I think I just answered you over on SymfonyCasts :). Delete the .babelrc file - that was leftover from the previous tutorial, and now causes issue (it references this outdated library). And we don't need this file anyways - Encore handles this detail automatically.

Cheers!

All 2 comments

It's now @babel/preset-env rather than babel-preset-env.

Hey @galens!

I think I just answered you over on SymfonyCasts :). Delete the .babelrc file - that was leftover from the previous tutorial, and now causes issue (it references this outdated library). And we don't need this file anyways - Encore handles this detail automatically.

Cheers!

Was this page helpful?
0 / 5 - 0 ratings