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
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.
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.
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" }
In my case, I had mis-spelled the loader while installing it, so make sure you install
babel-loader
NOT
bable-loader
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With