0

I am learning angular for about a month. I am following a series of video that I've found in internet. I got stuck here in this error as shown in picture below.

Error

webpack.server.config.js code

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

module.exports = {
entry: { server: './server.ts' },
resolve: { extentions: ['.js', '.ts'] },
externals: [/{node_modules|main\..*\.js}/],
output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].js'
},
module: {
    rules: {
        test: /\.ts$/,
        loader: 'ts-loader'
    }
},
plugins: [
    new webpack.ContextReplacementPlugin(
        /(.+)?angular(\\|\/)core(.+)?/,
        path.join(__dirname, 'src'),
        {}
    ),
    new webpack.ContextReplacementPlugin(
        /(.+)?express(\\|\/)(.+)?/,
        path.join(__dirname, 'src'),
        {}
    )
  ]
}

Package.json enter image description here

1 Answer 1

1

The clues are right there in the error message. rules needs to be an array of objects, not a single object; and extensions is spelled with an s where you have a second t.

Here is the fixed version:

webpack.server.config.js code

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

module.exports = {
entry: { server: './server.ts' },
resolve: { extensions: ['.js', '.ts'] }, // CHANGED
externals: [/{node_modules|main\..*\.js}/],
output: {
    path: path.join(__dirname, 'dist'),
    filename: '[name].js'
},
module: {
    rules: [{                           // CHANGED
        test: /\.ts$/,
        loader: 'ts-loader'
    }]                                  // CHANGED
},
plugins: [
    new webpack.ContextReplacementPlugin(
        /(.+)?angular(\\|\/)core(.+)?/,
        path.join(__dirname, 'src'),
        {}
    ),
    new webpack.ContextReplacementPlugin(
        /(.+)?express(\\|\/)(.+)?/,
        path.join(__dirname, 'src'),
        {}
    )
  ]
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you it works. I have some error. But I try to solve it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.