0

I'm a beginner. Please help me with the following error:

WARNING in ./node_modules/glob-watcher/node_modules/chokidar/lib/fsevents-handler.js 7:17-36 Module not found: Error: Can't resolve 'fsevents' in 'C:..\node_modules\glob-watcher\node_modules\chokidar\lib'

  • Chokidar version : "^3.5.3"
  • OS version: Windows 10 Pro N
  • npm v9.3.1

I have tried the following options:

  • npm install --no-optional - It did not help, after using the command I get the same error;
  • resolve: { fallback: { "fsevents": false } }; - the error is not displayed, but other modules still work incorrectly;
  • rm -rf node_modules / rm package-lock.json / npm install - have the same error.

webpack.dev.js

import fs from 'fs';
import FileIncludeWebpackPlugin from 'file-include-webpack-plugin-replace';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import CopyPlugin from "copy-webpack-plugin";

import * as path from 'path';

const srcFolder = "src";
const builFolder = "dist";
const rootFolder = path.basename(path.resolve());

let pugPages = fs.readdirSync(srcFolder).filter(fileName => fileName.endsWith('.pug'))
let htmlPages = [];

if (!pugPages.length) {
    htmlPages = [new FileIncludeWebpackPlugin({
        source: srcFolder,
        htmlBeautifyOptions: {
            "indent-with-tabs": true,
            'indent_size': 3
        },
        replace: [
            { regex: '<link rel="stylesheet" href="css/style.min.css">', to: '' },
            { regex: '../img', to: 'img' },
            { regex: '@img', to: 'img' },
            { regex: 'NEW_PROJECT_NAME', to: rootFolder }
        ],
    })];
}

const paths = {
    src: path.resolve(srcFolder),
    build: path.resolve(builFolder)
}

const config = {
    mode: "development",
    devtool: 'inline-source-map',
    optimization: {
        minimize: false
    },
    entry: [
        `${paths.src}/js/app.js`
    ],
    output: {
        path: `${paths.build}`,
        filename: 'js/app.min.js',
        publicPath: '/'
    },
    devServer: {
        historyApiFallback: true,
        static: paths.build,
        open: true,
        compress: true,
        port: 'auto',
        hot: true,
        host: 'local-ip', // localhost
        watchFiles: [
            `${paths.src}/**/*.html`,
            `${paths.src}/**/*.pug`,
            `${paths.src}/**/*.htm`,
            `${paths.src}/img/**/*.*`
        ],
    },
   module: {
        rules: [
            {
                test: /\.(scss|css)$/,
                exclude: `${paths.src}/fonts`,
                use: [
                    'style-loader',
                    {
                        loader: 'string-replace-loader',
                        options: {
                            search: '@img',
                            replace: '../img',
                            flags: 'g'
                        }
                    }, {
                        loader: 'css-loader',
                        options: {
                            sourceMap: true,
                            importLoaders: 1,
                            modules: false,
                            url: {
                                filter: (url, resourcePath) => {
                                    if (url.includes("img/") || url.includes("fonts/")) {
                                        return false;
                                    }
                                    return true;
                                },
                            },
                        },
                    }, {
                        loader: 'sass-loader',
                        options: {
                            sourceMap: true,
                        }
                    }
                ],
            }, {
                test: /\.pug$/,
                use: [
                    {
                        loader: 'pug-loader'
                    }, {
                        loader: 'string-replace-loader',
                        options: {
                            search: '@img',
                            replace: 'img',
                            flags: 'g'
                        }
                    }
                ]
            }
        ],
    },
   plugins: [
        ...htmlPages,
        ...pugPages.map(pugPage => new HtmlWebpackPlugin({
            minify: false,
            template: `${srcFolder}/${pugPage}`,
            filename: `${pugPage.replace(/\.pug/, '.html')}`
        })),
        new CopyPlugin({
            patterns: [
                {
                    from: `${srcFolder}/img`, to: `img`,
                    noErrorOnMissing: true,
                    force: true
                }, {
                    from: `${srcFolder}/files`, to: `files`,
                    noErrorOnMissing: true,
                    force: true
                }, {
                    from: `${paths.src}/favicon.ico`, to: `./`,
                    noErrorOnMissing: true
                }
            ],
        }),
    ],
    resolve: {
        alias: {
            "@scss": `${paths.src}/scss`,
            "@js": `${paths.src}/js`,
            "@img": `${paths.src}/img`
      },
      fallback: {
         "fs": false,
         "tls": false,
         "net": false,
         "path": false,
         "zlib": false,
         "http": false,
         "https": false,
         "stream": false,
         "crypto": false,
         "os": false,
         "domain": false,
         "assert": false,
         "constants": false,
      } 
   },
}
export default config;

package.json

{
    "name": "hamster-start",
    "version": "3.0.0",
    "description": "Start template with Gulp and Webpack",
    "author": "hamster",
    "private": true,
    "license": "",
    "type": "module",
    "scripts": {
        "dev": "gulp && webpack serve --progress -c config/webpack.dev.js",
        "build": "gulp build --build",
        "sprite": "gulp sprite",
        "fonts": "gulp fonts --rewrite",
        "deploy": "gulp deployFTP --build",
        "zip": "gulp deployZIP --build",
        "devbuild": "gulp build --build --nowebp",
        "tmp": "gulp -f gulpfile.tmp.js",
        "bem": "hamster-bemtree-from-html"
    },
    "devDependencies": {
        "copy-webpack-plugin": "latest",
        "css-loader": "latest",
        "del": "^6.1.1",
        "file-include-webpack-plugin-replace": "latest",
        "fls-bemtree-from-html": "^1.0.0",
        "gulp": "latest",
        "gulp-autoprefixer": "latest",
        "gulp-clean-css": "latest",
        "gulp-fonter-fix": "latest",
        "gulp-group-css-media-queries": "latest",
        "gulp-if": "latest",
        "gulp-imagemin": "^7.1.0",
        "gulp-newer": "latest",
        "gulp-notify": "latest",
        "gulp-plumber": "latest",
        "gulp-prettier": "latest",
        "gulp-rename": "latest",
        "gulp-svg-sprite": "latest",
        "gulp-ttf2woff": "latest",
        "gulp-ttf2woff2": "latest",
        "gulp-util": "latest",
        "gulp-version-number": "latest",
        "gulp-webp": "latest",
        "gulp-webp-html-nosvg": "latest",
        "gulp-webpcss": "latest",
        "gulp-zip": "latest",
        "html-webpack-plugin": "latest",
        "inputmask": "latest",
        "lightgallery": "latest",
        "load-plugins": "latest",
        "mini-css-extract-plugin": "2.4.7",
        "nouislider": "latest",
        "pug": "latest",
        "pug-loader": "latest",
        "sass": "latest",
        "sass-loader": "latest",
        "smooth-scroll": "latest",
        "string-replace-loader": "latest",
        "style-loader": "latest",
        "swiper": "latest",
        "terser-webpack-plugin": "latest",
        "tippy.js": "latest",
        "transform-runtime": "0.0.0",
        "vanilla-lazyload": "latest",
        "vinyl-ftp": "latest",
        "webp-converter": "2.2.3",
        "webpack": "latest",
        "webpack-cli": "latest",
        "webpack-dev-server": "latest",
        "webpack-stream": "latest"
    },
    "dependencies": {
        "chokidar": "^3.5.3",
        "simplebar": "latest"
    }
}

0 Answers0