How to fix EBUSY error: in nodejs serveur using vite?

I work on a project with symfony 7 and i use vite js.

Config : Windows 11, vscode, node v20.13.1, npm v10.5.2

when i start the nodejs server, all is fine but randomly the server stop and i get this error :

node:events:497
throw er; // Unhandled 'error' event
^

Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys'
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (file:///{my path}/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:46061:10)
at NodeFsHandler._boundHandleError (file:///{my path}/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:44534:43)
at ReaddirpStream.emit (node:events:519:28)
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4082,
code: 'EBUSY',
syscall: 'lstat',
path: 'C:\pagefile.sys'
}

Node.js v20.13.1

I searched a lot but i didn’t found a solution. I tried to change version of node and npm, start vs code in admin mode, npm cache clear, delete node_modules…

Vite config :

import { defineConfig } from "vite";
import autoprefixer from "autoprefixer";
import { browserslistToTargets } from 'lightningcss';
import browserslist from 'browserslist';
import purgecss from '@fullhuman/postcss-purgecss';
import path, { resolve } from 'path';

const twigRefreshPlugin = {
    name: 'twig-refresh',
    configureServer ({ watcher, ws }) {
        watcher.add(resolve('templates/**/*.twig'));
        watcher.on('change', function (path) {
            if (path.endsWith('.twig')) {
                ws.send({
                    type: 'full-reload'
                });
            }
        });
    }
}

export default defineConfig({
    root: './',
    publicDir: path.resolve(__dirname, '/public'),
    plugins: [twigRefreshPlugin],
    css: {
        transformer: 'postcss',
        lightningcss: {
            targets: browserslistToTargets(browserslist('>= 0.25%'))
        },
        postcss: {
            plugins: [
                autoprefixer({}),
                purgecss({
                    content: [
                        './templates/**/*.html.twig',
                    ],
                    safelist: [
                        'menu-close',
                        'menu-open',
                        'dt-paging',
                        'dt-paging-button',
                        'dt-layout-cell',
                        'dt-container',
                        'dt-end',
                        'current',
                        'disabled',
                        'previous',
                        'next'
                    ],
                })
            ],
        },
    },
    server: {
        port: 1337,
        host: '0.0.0.0',
        watch: {
            disableGlobbing: false,
            //usePolling: true,
        }
    },
    build: {
        copyPublicDir: false,
        cssMinify: 'lightningcss',
        rollupOptions: {
            input: {
                style: './assets/sass/style.scss',
                app: './assets/ts/app.ts',
            },
            output: {
                dir: path.resolve(__dirname, 'public/dist'),
                format: 'es',
                entryFileNames: `[name].js`,
                chunkFileNames: `[name].js`,
                assetFileNames: `[name].[ext]`,
            },

        },

    },
});

The only solutin i found is to set usePolling: true but the server is more slowly, when i edit a scss file, the refresh will have a delay.

Thanks

The only solutin i found is to set usePolling: true but the server is more slowly, when i edit a scss file, the refresh will have a delay.

New contributor

Alexandre Ferreira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật