Webpack / Babel Error: Module build failed: (SystemJS) ENOENT: no such file or directory

1.9k views Asked by At

I'm looking for help with the following error when running webpack if anyone can kindly offer some advice. It seems to me that the path being used is develop/babel-core rather than develop/node_modules/babe-core but I may be off the mark here. Webpack and Babel are using the latest versions.

ERROR in ./js/scripts.js Module build failed: (SystemJS) ENOENT: no such file or directory, open
'/Users/dh/Documents/Websites/www.mpp.dev/wp-content/themes/develop/babel-core'
Error: ENOENT: no such file or directory, open
'/Users/dh/Documents/Websites/www.mpp.dev/wp-content/themes/develop/babel-core'

Error loading
/Users/dh/Documents/Websites/www.mpp.dev/wp-content/themes/develop/babel-core
as "babel-core" from
/Users/dh/Documents/Websites/www.mpp.dev/wp-content/themes/develop/node_modules/babel-loader/lib/index.js

ERROR in ./js/admin.js Module build failed: (SystemJS) ENOENT: no such
file or directory, open
'/Users/dh/Documents/Websites/www.mpp.dev/wp-content/themes/develop/babel-core'
Error: ENOENT: no such file or directory, open
'/Users/dh/Documents/Websites/www.mpp.dev/wp-content/themes/develop/babel-core'

Error loading
/Users/dh/Documents/Websites/www.mpp.dev/wp-content/themes/develop/babel-core
as "babel-core" from
/Users/dh/Documents/Websites/www.mpp.dev/wp-content/themes/develop/node_modules/babel-loader/lib/index.js

This is my config and I think the syntax is correct.

module.exports = {
    entry: {
        scripts: './js/scripts.js',
        admin: './js/admin.js',
    },
    output: {
        filename: 'build/js/[name].js',
        chunkFilename: 'build/js/[id].js'
    },
        module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules)/,
                use: {                                                                                                          loader: 'babel-loader',
        options: {
            presets: ['env']
        },                                                                      },
                }
            }
        ]
    }
}

Thanks in advance...

1

There are 1 answers

0
dancerphil On

I meet the similar question with /node_modules/babe-core not found, and I solved by:

npm install [email protected] --save-dev

see: babel-loader#242