Jieiku / abridge

Fast & Lightweight Zola Theme
https://abridge.pages.dev/
MIT License
142 stars 41 forks source link

npm run abridge fails on windows #160

Closed Brandon689 closed 2 weeks ago

Brandon689 commented 6 months ago

node:internal/errors:497 ErrorCaptureStackTrace(err); ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined at Object.writeFileSync (node:fs:2281:5) at minify (C:\blog\free\package_abridge.js:275:6) at abridge (C:\blog\free\package_abridge.js:184:5) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'ERR_INVALID_ARG_TYPE' }

man this theme is so insanely brittle

Jieiku commented 6 months ago

Believe me, I would love to avoid using npm/node, it is only used to make up for the shortcomings in Zola, like being unable to template a js file.

The message in that error is not very specific but I am thinking I can just add some error and type checking in the node script. Will push an update shortly, thank you for reporting this issue.

Jieiku commented 6 months ago

Just pushed a commit that adds a lot of error handling.

Update your abridge theme / submodule and let me know what error if any that you get now.

Thank You for submitting this report, it really helps to improve abridge!

Jieiku commented 6 months ago

I just added one more error catch, in the case of a missing config.toml: ce93f9a11091bdaf933ac8753e74bfbfee8622a4

I am not seeing anything else to error check on, so hopefully now it will give more meaningful error messages.

Brandon689 commented 6 months ago

it doesnt change the error message

Brandon689 commented 6 months ago

its because of Windows somehow, I dont have this issue on Linux. The whole timeline is I was fine, then the submodule way I used was bad cause I couldnt change the theme code. So I deleted the submodule the wrong way (this is all on my Manjaro laptop) and couldnt undo deleting it improperly. So I redid whole setup on my Windows 11 pc and it just does not work.

So now ive gone back to Linux and redone it and of course I see no errors. So its likely not an easy thing to fix.

Jieiku commented 6 months ago

ok, that is still helpful though. I think I will invest some time in documenting windows setup steps, it has been like 10+ years since I have used windows for anything other than gaming, so I am a bit out of touch with how some of this would even be done in windows.

You could try WSL (Windows subsystem for linux) on your windows machine in the mean time, if you would rather use that machine.

Documenting setup for native windows is on my radar, but it will be a bit before I have time to do it.

Brandon689 commented 6 months ago

Its something I run into more and more, I'd like to switch over to Linux fully but I use Visual Studio and love that IDE. I would save myself a lot of trouble if I used Linux as daily driver.

Jieiku commented 6 months ago

I thought Visual Studio runs fine on linux?

edit: woops only visual studio code.

Brandon689 commented 6 months ago

Even now I just had another Linux moment. I've been trying to setup Celery and RabbitMQ for periodic tasks and after all this effort and errors I find out that Celery doesn't actually promise that they support Windows and they don't expect anyone to do it.

Jieiku commented 2 weeks ago

I finally got around to this on windows and got the exact same error you did, no idea yet why it is trouble free on linux but not windows. Hopefully I can resolve it quickly.

The error happens on line 286 of package_abridge.js:

  result = UglifyJS.minify(filesContents, options);
  fs.writeFileSync(outfile, result.code);

If I comment out those two lines then the npm script runs fine, so it has something to do with the minify portion.

Jieiku commented 2 weeks ago

I figured it out, when the file list for BASE_CACHE_FILES is generated (which is part of the PWA feature) on windows the path contains backslashes \ but on linux they are forward slashes / , this causes big problems with the javascript file because backslashes \ are an escape character. So when uglifyjs tries to minify the sw.js file it errors out.

I will work this out and fix it soon.

Jieiku commented 2 weeks ago

This is now resolved: https://github.com/Jieiku/abridge/commit/ce2044a3bb12311ad90386c0c3875fa7fa098ffa