parcel: Parcel Serve 2.8.0 randomly crashes while rebuilding

After editing an HTML file and resaving, parcel will occasionally bomb out with the following trace.

Not repeatable, but this never happened with the previous 2.7.0 build.

Server running at http://localhost:1234
\ Building index.html...
node:internal/fs/utils:347
    throw err;
    ^

Error: ENOENT: no such file or directory, unlink 'C:\Rascular\ViewMaster\dist\index.html.2508.m'
    at Object.unlinkSync (node:fs:1767:3)
    at NodeFS.unlinkSync (C:\Rascular\ViewMaster\.pnp.cjs:5919:24)
    at makeCallSync.subPath.subPath (C:\Rascular\ViewMaster\.pnp.cjs:8166:26)
    at ZipOpenFS.makeCallSync (C:\Rascular\ViewMaster\.pnp.cjs:8379:14)
    at ZipOpenFS.unlinkSync (C:\Rascular\ViewMaster\.pnp.cjs:8165:17)
    at VirtualFS.unlinkSync (C:\Rascular\ViewMaster\.pnp.cjs:7463:24)
    at PosixFS.unlinkSync (C:\Rascular\ViewMaster\.pnp.cjs:7463:24)
    at URLFS.unlinkSync (C:\Rascular\ViewMaster\.pnp.cjs:7463:24)
    at WriteStream.<anonymous> (C:\Rascular\ViewMaster\.yarn\__virtual__\@parcel-fs-virtual-99d78ac16b\0\cache\@parcel-fs-npm-2.8.0-30a533924e-75d79963a1.zip\node_modules\@parcel\fs\lib\index.js:1019:83)
    at Object.onceWrapper (node:events:628:26) {
  errno: -4058,
  syscall: 'unlink',
  code: 'ENOENT',
  path: 'C:\\Rascular\\ViewMaster\\dist\\index.html.2508.m'

🌍 Your Environment

Software Version(s)
Parcel 2.8.0
Node 16.18.0
npm/Yarn Yarn 3.2.4
Operating System Windows 11

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 18
  • Comments: 34 (1 by maintainers)

Most upvoted comments

I have the same problem. All I did was start up a brand new parcel project and install tailwindcss following their guide on using it with parcel. It ran fine. Then I deleted “hello world” from the HTML file and it crashed

Error: ENOENT: no such file or directory, unlink 'C:\Test\website\dist\index.html.19376.8'
    at Object.unlinkSync (node:fs:1767:3)
    at WriteStream.<anonymous> (C:\Test\website\node_modules\@parcel\fs\lib\index.js:1028:83)
    at Object.onceWrapper (node:events:628:26)
    at WriteStream.emit (node:events:525:35)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {      
  errno: -4058,
  syscall: 'unlink',
  code: 'ENOENT',
  path: 'C:\\Test\\website\\dist\\index.html.19376.8'

I can reproduce it every time. Just run npx parcel src/index.html and modify the HTML file two times. I also have auto save on VS code.

I was able to fix this crashing problem by merely fixing my content configuration inside tailwindcss.config.js file. It seemed to crash when it was unable to find the specific path I wrote inside the content property. So, I did the following to fix the issue:

/** @type {import('tailwindcss').Config} */
module.exports = {
-     content: ["./*.html"],
+    content: ["./src/**/*.{html, js, tsx, jsx, ts}"],
  theme: {
    extend: {},
  },
  plugins: [],
}

Save error, parcel keeps on crashing on rebuilding (maybe when I save twice?):

Parcel: 2.8.3 on Windows 11.

Server running at http://localhost:1234
🚨 Build failed.
Server running at http://localhost:1234
- Optimizing index.[hash].js...
internal/fs/utils.js:308
    throw err;
    ^

Error: ENOENT: no such file or directory, unlink '...\dist\index.2d3ace14.js.484.1w'
    at Object.unlinkSync (fs.js:1210:3)
    at WriteStream.<anonymous> (...\node_modules\@parcel\core\node_modules\@parcel\fs\lib\index.js:1019:83)
    at Object.onceWrapper (events.js:422:26)
    at WriteStream.emit (events.js:327:22)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -4058,
  syscall: 'unlink',
  code: 'ENOENT',
  path: '...\dist\\index.2d3ace14.js.484.1w'
}

Ok, found a way to reproduce the crash with Error: ENOENT: no such file or directory, unlink:

  • Have parcel running
  • Have the website open in your browser
  • Have DevTools open with “Pause on uncaught exceptions”
  • Introduce an exception error in your code (e.g. console.log(undefined_variable))
  • Save the file (so the app is reloaded and the browser pauses)
  • Fix the error (remove the exception) and save the file again
  • Because the app compiles BUT the browser JS execution is still paused (on debugger), Parcel crashes for some reason:
Error: ENOENT: no such file or directory, unlink 'C:\wamp64\www\userTrack\dist\index.2d3ace14.js.20660.3q'
    at Object.unlinkSync (node:fs:1883:3)
    at WriteStream.<anonymous> (C:\wamp64\www\userTrack\node_modules\@parcel\fs\lib\index.js:1028:83)
    at Object.onceWrapper (node:events:629:26)
    at WriteStream.emit (node:events:526:35)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  syscall: 'unlink',
  code: 'ENOENT',
  path: 'C:\\wamp64\\www\\userTrack\\dist\\index.2d3ace14.js.20660.3q'
}

So, to trigger the crash in 2 seconds, with dev tools open and “Pause on exceptions on”, add this line console.log(undefined_variable), save the file, comment the line, save the file again.

We made a workaround. We created a ‘cleanup’ script who celan the .parcel-cache and dist folder.

"scripts": {
    "cleanup": "rimraf .parcel-cache dist",
    "dev": "npm run cleanup && parcel ./src/index.html --no-cache",
    "prebuild": "npx rimraf build",
    "build": "parcel build --public-url ./ ./src/index.html --no-cache"
  },

maybe the problema is concurrency and file lock in the .parcel-cache folder

Can consistently repeat this issue in Win 11, with latest Parcel version (2.8.1) and Node 16, Node 19, quite annyoing, quickly writing, saving, deleting few chars, saving again in html file, instantly introduces this issue

Never experienced this on macOS with same project.

image

I have tried removing, enabling HMR, changing config, passing various flags, basically no success. Maybe there is some flag to bypass all cache and random file names, as a quick workaround?

Might be solved with https://github.com/parcel-bundler/parcel/pull/8616/


After applying changes from https://github.com/parcel-bundler/parcel/pull/8616/ as yarn patch, it seemed to improve, but now I got another error:

× Build failed.

@parcel/compressor-raw: EPERM: operation not permitted, rename D:\test\dist\index.html.12768.5c' -> 'D:\test\dist\index.html'

  Error: EPERM: operation not permitted, rename 'D:\test\dist\index.html.12768.5c' -> 'D:\test\dist\index.html'

Slightly different error trace here:

- Building cv.html...
node:internal/fs/utils:345
    throw err;
    ^

Error: ENOENT: no such file or directory, unlink 'C:\Users\Elias\Desktop\cv\dist\cv.html.17068.k'
    at Object.unlinkSync (node:fs:1735:3)
    at WriteStream.<anonymous> (C:\Users\Elias\AppData\Roaming\npm\node_modules\parcel\node_modules\@parcel\fs\lib\index.js:1019:83)
    at Object.onceWrapper (node:events:642:26)
    at WriteStream.emit (node:events:539:35)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  syscall: 'unlink',
  code: 'ENOENT',
  path: 'C:\\Users\\Elias\\Desktop\\cv\\dist\\cv.html.17068.k'
}
Software Version
Parcel 2.8.0
Node v16.16.0
npm 8.13.2
Operating System Windows 11

Maybe related to different versions of Node? 🤷

For me, this is sadly happening quite frequently.

Also hitting this issue. Was quite excited to use parcel as it worked really well on MacOS. Sadly the exact same project hits this error on W10.

The only workaround I’ve found to mitigate this issue is to disable HMR (--no-hmr).

Which, of course, is not the greatest DX; but at least I’m not restarting Parcel every other file save.

@mischnic

Ok, found a way to reproduce the crash with Error: ENOENT: no such file or directory, unlink:

  • Have parcel running
  • Have the website open in your browser
  • Have DevTools open with “Pause on uncaught exceptions”
  • Introduce an exception error in your code (e.g. console.log(undefined_variable))
  • Save the file (so the app is reloaded and the browser pauses)
  • Fix the error (remove the exception) and save the file again
  • Because the app compiles BUT the browser JS execution is still paused (on debugger), Parcel crashes for some reason:
Error: ENOENT: no such file or directory, unlink 'C:\wamp64\www\userTrack\dist\index.2d3ace14.js.20660.3q'
    at Object.unlinkSync (node:fs:1883:3)
    at WriteStream.<anonymous> (C:\wamp64\www\userTrack\node_modules\@parcel\fs\lib\index.js:1028:83)
    at Object.onceWrapper (node:events:629:26)
    at WriteStream.emit (node:events:526:35)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  syscall: 'unlink',
  code: 'ENOENT',
  path: 'C:\\wamp64\\www\\userTrack\\dist\\index.2d3ace14.js.20660.3q'
}

So, to trigger the crash in 2 seconds, with dev tools open and “Pause on exceptions on”, add this line console.log(undefined_variable), save the file, comment the line, save the file again.

Happening for me as well (VSC 1.77.0). Running Node v18.12.0 and it crashes randomly when I update a file (html, js, scss).