0

I am upgrading npm packages for a React project with 3-4 years behind. I managed to upgrade all npm packages and clean up webpack. However, when I run npm start , I have 2 errors as below:

enter image description here

In fact, I do not have this file : babel-virtual-resolve-base.js as produced on the terminal.

webpack.config.server.js

const path = require('path');
const webpack = require('webpack');

const outputPath = process.env.MODE === 'watch' ? 'C:\\{{yourFolder}}\\{yourFolder}\\Website' : path.join(__dirname, '../../../Project/{yourFolder}/code/Content/');
const outputFilename = `scripts/app.[name].js`;

const config = {
    mode: 'none',
    context: path.resolve(__dirname, './src'),
    entry: {
        server: ['babel-polyfill', path.join(__dirname, '../scripts/server/index.js')]
    },
    output: {
        path:  outputPath,
        publicPath: '/',
        filename: outputFilename
    },
    resolve: {
        extensions: ['.js', '.jsx'],
        alias: {
            moment$: 'moment/moment.js', // added to fix bug with moment 2.19
        }
    },
    module: {
        rules: [
            // Scripts
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                use:  {
                    loader: 'babel-loader',
                    options: {
                        presets: [
                            [
                                'env',
                                {
                                    'targets': {
                                        'browsers': ['last 2 versions', 'ie >= 10']
                                    },
                                    'modules': false
                                }
                            ],
                            'stage-0', 'react'],
                        plugins: ['transform-decorators-legacy']
                    }
                }
            }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify(process.env.NODE_ENV),
                IS_BROWSER: false
            }
        }),
        new webpack.IgnorePlugin({
            resourceRegExp: /^\.\/locale$/,
            contextRegExp: /moment$/,
        })
    ]
};

// Conditional plugin options
if (process.env.NODE_ENV === 'production' ) {
    config.plugins.push(
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                screw_ie8: true
            }
        }),
        new webpack.optimize.AggressiveMergingPlugin()
    );
} else {
    config.devtool = 'inline-source-map';
}

module.exports = config;

server folder: index.js

require('expose-loader?React!react');
require('expose-loader?ReactDOM!react-dom');
require('expose-loader?Components!./components');

I have been searching around but I can't find the correct answers.

0 Answers0