Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with babel-polyfill and webpack

I am following along a tutorial from Udemy, and we've just downloaded babel. Everything was working fine until I downloaded babel-polyfill and tried to integrate it.

Currently this is my webpack and babelrc files: Webpack & Babel and this is what the error looks like on the command line: Command Line Error.

Does anyone know what I'm doing wrong? Thanks in advance for all your help!

like image 481
Leslie O Avatar asked Jun 20 '18 00:06

Leslie O


People also ask

Can t resolve babel polyfill webpack?

The key error there is Cannot resolve babel-polyfill in... This means webpack isn't able to find that module in your node_modules folder. Check to make sure it's there in node_modules/babel-polyfill and if not install it with npm install --save babel-polyfill .

What can I use instead of Babel polyfill?

core-js is currently replacing bable-polyfill. You do not have to set it anywhere except for the . babelrc file I have a question, why do you duplicate libraries you have @babel/polyfill and babel-pollyfill the same applies to @babel/preset-env and babel-preset-en .

Does babel do polyfill?

Babel includes a polyfill that includes a custom regenerator runtime and core-js. This will emulate a full ES2015+ environment (no < Stage 4 proposals) and is intended to be used in an application rather than a library/tool. (this polyfill is automatically loaded when using babel-node ).

Where to add babel polyfill?

To include the polyfill you need to require it at the top of the entry point to your application. Make sure it is called before all other code/require statements!


1 Answers

The key error there is Cannot resolve babel-polyfill in...

This means webpack isn't able to find that module in your node_modules folder. Check to make sure it's there in node_modules/babel-polyfill and if not install it with npm install --save babel-polyfill.

If it's there and you still get this error, there are a few possible reasons.

Make sure the permissions on the files/folders are ok. Check that you don't have any NODE_PATH env var set or there's no modulesDirectory setting in your webpack.config.js set that would cause webpack to look in the wrong directory.

like image 145
Jonathan Dumaine Avatar answered Nov 05 '22 23:11

Jonathan Dumaine