Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot resolve module 'babel-loader'

I'm trying to run webpack on my postinstall script in my package.json when I push to heroku but I am getting the following error.

ERROR in Entry module not found: Error: Cannot resolve module 'babel-loader' in /tmp/build_6cb4b10367d9382367ab72f2e2f33118 

When I run the command locally I get no issues. Below is my webpack config - i have tried using resolveLoader to fix the resolving issue but to no avail?

var path = require('path'); var webpack = require('webpack');  var config = {   entry: path.resolve(__dirname, './app/main.js'),   output: {     path: path.resolve(__dirname, 'dist'),     filename: 'bundle.js'   },   module: {     loaders: [       {         test: /\.js$/,         exclude: /node_modules/,         loader: 'babel-loader'       },       {         test: /\.less$/,         loader: 'style!css!less'       }]   },   resolve: {     extensions: ['', '.js', '.jsx', '.less'],     modulesDirectories: [       'node_modules'     ]   },   resolveLoader: {     root: path.resolve(__dirname, 'node_modules')   },   plugins: [     new webpack.optimize.UglifyJsPlugin({minimize: true})   ] };  module.exports = config; 

Any suggestions? Thanks

like image 865
Geraint Avatar asked Dec 30 '15 22:12

Geraint


People also ask

Can not Resolve Babel loader?

To solve the error "Module not found: Error: Can't resolve 'babel-loader'", make sure to install the babel-loader package by opening your terminal in your project's root directory and running the command npm install -D babel-loader and restart your development server.

Can not find Babel core?

To solve the error "Cannot find module '@babel/core'", make sure to install the @babe/core package by opening your terminal in your project's root directory and running the following command: npm i -D @babel/core and restart your IDE and development server.


2 Answers

I found out why. I didn't have babel or babel-core in my package.json. Add them fixed the error.

  "devDependencies": {     "babel": "^5.8.23",     "babel-core": "^5.0.0",     "babel-loader": "^5.3.2" } 
like image 75
Geraint Avatar answered Sep 18 '22 09:09

Geraint


In my case, I had mis-spelled the loader while installing it, so make sure you install

babel-loader

NOT

bable-loader

like image 34
Prakash Tiwari Avatar answered Sep 22 '22 09:09

Prakash Tiwari