简体   繁体   中英

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

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...

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

npm install postcss-import@8.0.2 --save-dev

see: babel-loader#242

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM