Skip to content
This repository was archived by the owner on Oct 30, 2020. It is now read-only.
This repository was archived by the owner on Oct 30, 2020. It is now read-only.

Module build failed error #89

Description

@Webbrother

I'm trying to use this loader but I get an error.

Uncaught Error: Module build failed (from ./node_modules/typings-for-css-modules-loader/lib/index.js):
Error: Cannot find module 'css-loader/locals'
    at Function.Module._resolveFilename (:9000/internal/modules/cjs/loader.js:611)
    at Function.Module._load (:9000/internal/modules/cjs/loader.js:537)
    at Module.require (:9000/internal/modules/cjs/loader.js:665)
    at require (:9000/internal/modules/cjs/helpers.js:20)
    at Object.<anonymous> (:9000/Users/Vega/projects/frontend-environment/client/node_modules/typings-for-css-modules-loader/lib/index.js:9)
    at Module._compile (:9000/internal/modules/cjs/loader.js:736)
    at Object.Module._extensions..js (:9000/internal/modules/cjs/loader.js:747)
    at Module.load (:9000/internal/modules/cjs/loader.js:628)
    at tryModuleLoad (:9000/internal/modules/cjs/loader.js:568)
    at Function.Module._load (:9000/internal/modules/cjs/loader.js:560)
    at Object../node_modules/typings-for-css-modules-loader/lib/index.js?!./src/css/index.css (bootstrap:151)
    at __webpack_require__ (bootstrap:78)
    at Object../src/css/index.css (index.css:2)
    at __webpack_require__ (bootstrap:78)
    at Module../src/index.ts (index.ts:1)
    at __webpack_require__ (bootstrap:78)
    at Object.0 (module1.ts:11)
    at __webpack_require__ (bootstrap:78)
    at checkDeferredModules (bootstrap:45)
    at bootstrap:151

My webpack config:

var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

let distPath = path.resolve(__dirname, 'dist');

module.exports = {
    entry: './src/index.ts',
    output: {
        path: distPath,
        chunkFilename: '[name]-[contenthash].chunk.js',
        filename: '[name]-[contenthash].js'
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/
            },
            {
                test: /\.js$/,
                loader: 'babel-loader',
                query: {
                    presets: ['@babel/env']
                },
                exclude: [/node_modules/]
            }
            , {
                test: /\.(html)$/,
                use: [{
                    loader: 'html-loader',
                    options: {
                        attrs: false
                    }
                }]
            }
            , {
                test: /\.(jpg|jpeg|png|gif)$/,
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 1,
                        name: `img/[name]-[hash].[ext]`
                    }
                }]
            }, {
                test: /\.css$/,
                use: [
                    {
                        loader: "style-loader"
                    }, {
                        loader: 'typings-for-css-modules-loader',
                        options: {
                            modules: true,
                            namedExport: true,
                            camelCase: true
                        }
                    }
                ]
            }
        ]
    },
    resolve: {
        extensions: [ '.tsx', '.ts', '.js', ',css', '*' ]
    },
    stats: {
        colors: true
    },
    devtool: 'inline-source-map',
    devServer: {
        host: '0.0.0.0',
        port: 9000,
        open: true
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './index.html'
        }),
        new CleanWebpackPlugin(['dist'])
    ],
    optimization: {
        usedExports: true,
        splitChunks: {
            chunks: 'all',
            minSize: 1,
            name: true
        }
    }
};

What do I do wrong?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions