1

Using Webpack 5 and the latest version of moment-timezone I get the following error. Please note that even without json-loader, which should not be necessary, I still get this error.

ERROR in ./node_modules/moment-timezone/data/packed/latest.json
Module parse failed: Unexpected token "m" (0x6D) in JSON at position 0 while parsing near "module.exports = {\"v..."
File was processed with these loaders:
 * ./node_modules/json-loader/index.js
You may need an additional loader to handle the result of these loaders.
JSONParseError: Unexpected token "m" (0x6D) in JSON at position 0 while parsing near "module.exports = {\"v..."

Going into node_modules, latest.json is just a json file, there is no module.exports

Relevant part of webpack.common.js

resolve: {
        alias: {
            Factories: path.resolve(__dirname, '../tests/factories'),
            Components: path.resolve(__dirname, '../src/static/js/components'),
            Icons: path.resolve(__dirname, '../src/static/js/components/icons'),
            Util: path.resolve(__dirname, '../src/static/js/util'),
            '@': path.resolve(__dirname, '../src'),
            Http: path.resolve(__dirname, '../src/static/js/http_service.js'),
            Img: path.resolve(__dirname, '../src/static/img/'),
            Types: path.resolve(__dirname, '../libs/types')
        },
        extensions: ['.ts', '.js', '.vue', '.gql', '.json'],
        fallback: {
            stream: false,
            buffer: require.resolve('buffer/')
        }
    },
    module: {
        rules: [
            { 
                test: /\.m?js/,
                type: "javascript/auto",
                resolve: {fullySpecified: false},
                exclude: /node_modules\/(?!(graphql)\/).*/,

            },
            {
                test: /\.json$/,
                loader: 'json-loader'
            },
...

0 Answers0