9

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!

Leslie O
  • 193
  • 1
  • 1
  • 8

2 Answers2

14

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.

Jonathan Dumaine
  • 5,575
  • 3
  • 38
  • 50
  • Thanks for getting back to me. It looks like babel-polyfill is in the node_modules folder. I don't exactly know know what you mean by "Check that you don't have any NODE_PATH env var set" but there is no modulesDirectory setting in my webpack config. Unfortunately it is still not working. – Leslie O Jun 20 '18 at 01:24
  • You're gonna have to share the code at this point for someone to figure it out. Post it on Github. – Jonathan Dumaine Jun 20 '18 at 01:46
  • For those who are struggling with it even though you did everything well. In my case, I installed global and local npm at the same time so I removed local one and it works well. Thank you. – sunsets Jul 22 '20 at 05:04
5

I figured it out. Looks like I was misspelling 'polyfill' in my webpack configuration. D'oh!

Leslie O
  • 193
  • 1
  • 1
  • 8