codeX
codeX

Reputation: 5428

Module not found: Error: Can't resolve 'babel-loader'

Just I did my web pack upgrade from 2.x to 4.x. By doing npm install i was getting the following error

Module not found: Error: Can't resolve 'babel-loader' 

Following the github thread , i added the following lines in webpack.config.json

 resolveLoader: {   root: path.join(__dirname, 'node_modules') }

But i got the following error ,

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.resolveLoader has an unknown property 'modulesDirectories'. These properties are valid: object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }

babel-loader version is 7.1.4 . Webpack upgrade has introduced this error. Any suggestions on this?

Upvotes: 0

Views: 6051

Answers (2)

Hazem Alabiad
Hazem Alabiad

Reputation: 1052

Just install the module:

npm install babel-loader

or

yarn add babel-loader

I got this problem fixed by running the above command.

Upvotes: 2

Dhanan
Dhanan

Reputation: 207

Aren't you install this "babel-loader" https://www.npmjs.com/package/babel-loader

module: {
    rules: [{
        test: /\.jsx?$/,
        include: [
            path.resolve(__dirname, 'src/js'),
        ],
        loader: "babel-loader",
        options: {
            presets: ["es2015"],
            plugins: [
                ["babel-plugin-root-import", {
                    "rootPathSuffix": "src/js"
                }],
                [
                    "transform-runtime", {
                        "helpers": false,
                        "polyfill": false,
                        "regenerator": true,
                        "moduleName": "babel-runtime"
                    }
                ],
                "transform-object-assign", "transform-function-bind"
            ]
        },
        // options for the loader
    }}

Upvotes: 0

Related Questions