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.
Alexandre Ferreira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.