Code Monkey home page Code Monkey logo

Comments (14)

TimGeisler avatar TimGeisler commented on September 26, 2024 6

I tried to install pagefind on Windows 10 with 4 different shells: cmd, Powershell, git bash, cygwin bash.
For each of the cases, I created a new NPM package using npm init and accepting all defaults.
With cmd and Powershell, installation worked fine (node_modules was created, pagefind folder exists).
On both git bash and cygwin bash, I got similar error messages:

$ npm install --save-dev pagefind
npm ERR! code 1
npm ERR! path C:\Users\tg\pagefind\gitbash\node_modules\pagefind
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./lib/postinstall.js
npm ERR! Finding release for v0.8.0
npm ERR! https://api.github.com/repos/CloudCannon/pagefind/releases/tags/v0.8.0
npm ERR! GET https://api.github.com/repos/CloudCannon/pagefind/releases/tags/v0.8.0
npm ERR! Downloading from https://api.github.com/repos/CloudCannon/pagefind/releases/assets/75547266
npm ERR! Downloading to C:\Users\tg\pagefind\gitbash\node_modules\pagefind\cache\0.8.0\pagefind_extended-v0.8.0-x86_64-pc-windows-msvc.tar.gz
npm ERR! Downloading with Invoke-WebRequest
npm ERR! Unzipping to C:\Users\tg\pagefind\gitbash\node_modules\pagefind\bin
npm ERR! tar xvf exited with 128
npm ERR! Deleting invalid download
npm ERR! tar: Cannot connect to C: resolve failed
npm ERR! Downloading pagefind failed: Error: tar xvf exited with 128
npm ERR!     at ChildProcess.<anonymous> (C:\Users\tg\pagefind\gitbash\node_modules\pagefind\lib\download.js:217:24)
npm ERR!     at ChildProcess.emit (node:events:390:28)
npm ERR!     at maybeClose (node:internal/child_process:1064:16)
npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)

Thus, it seems that the unpacking of the tar.gz file does not work on Windows with git bash/cygwin bash.

from pagefind.

TimGeisler avatar TimGeisler commented on September 26, 2024 1

When you rename pagefind_extended to pagefind_extended.exe, it works with cmd and Powershell, respectively:
grafik

from pagefind.

TimGeisler avatar TimGeisler commented on September 26, 2024 1

The reason why the .exe extension is missing is that the tar files for Windows contain the executables without .exe extension which does not fit together which what is implemented in

path.join(__dirname, `../bin/pagefind_extended${process.platform === 'win32' ? '.exe' : ''}`),

from pagefind.

bglw avatar bglw commented on September 26, 2024 1

Thanks for the deep dive @TimGeisler 🙏 I'm away from my keyboard this week but I will look at tidying that up when I'm back in a few days 🙂

It looks like changing the files in the tar archive to end in .exe will fix one problem. Additionally the tar xvf throwing an error needs to be looked into — I might swap that command out for a library like tar to try and sidestep any platform/shell specific errors.

from pagefind.

TimGeisler avatar TimGeisler commented on September 26, 2024

I have the same problem with Windows. Try to run directly the executable node_modules/pagefind/bin/pagefind_extended.

from pagefind.

rawriddims avatar rawriddims commented on September 26, 2024

You mean npx run node_modules/pagefind/bin/pagefind and then run it in my package.json? npx, right?

from pagefind.

TimGeisler avatar TimGeisler commented on September 26, 2024

No, first install pagefind by adding it to your devDependencies. Then try to execute the executable in this folder directly (e.g. in your Powershell). That works for me.
However, we still need to find out the exact reason of the problems for Windows. There are more than one way where you can run the npx script: in cmd, in git bash, in cygwin, in PowerShell. I guess some parts of the extraction/recognition logic do not handle all those different settings. I need to find some time to look into that the next days.

from pagefind.

rawriddims avatar rawriddims commented on September 26, 2024

So, I did npm install pagefind --save-dev and here it is in the package,json:

  "devDependencies": {
    "@11ty/eleventy": "^0.12.1",
    "pagefind": "^0.8.0"
  },

Then I had to cd (3 times) down upto \node_modules\pagefind\bin and run the binary directly ./pagefind_extended --source "_site"
But nothing happens, except a Windows prompt which asks me "How do you like to open this file?".

Obviously I'm doing something wrong,

PS I'm doing it in PowerShell.

from pagefind.

TimGeisler avatar TimGeisler commented on September 26, 2024

When I try to run the created file node_modules/pagefind/bin/pagefind_extended in both cmd and Powershell, I get the behaviour which @rawriddims observed.

However, when I try to run these files with bash (git or cygwin), the executable is running:
grafik

Of course, you then have to specify the source folder, ...

from pagefind.

TimGeisler avatar TimGeisler commented on September 26, 2024

Unfortunately, I am not an expert to get those install/postinstall/... scripts working on all different shells on Windows. The combination of installing/unpacking with cmd/Powershell and running with bash worked for me. This helps for trying it out, but is not a solution if you develop on Windows.

from pagefind.

rawriddims avatar rawriddims commented on September 26, 2024

It's a bit too cumbersome for me, as I have to develop on Windows. Maybe I should wait for the .exe extension to be added to the Windows executables, or maybe for a plain Windows installation - if that's in the plans for the future. I look forward to see such developments of this excellent library. Thank you. And thank you very much @TimGeisler for the help and directions on how to proceed in my case.

from pagefind.

bglw avatar bglw commented on September 26, 2024

Sorry for the delay all — this should be fixed by #113 — aiming for a release this week 🙂

from pagefind.

bglw avatar bglw commented on September 26, 2024

👋 Hello! This is fixed in the Pagefind v0.9.1 release 🎉

from pagefind.

whyboris avatar whyboris commented on September 26, 2024

Thank you @TimGeisler 🙇 for solving the error I was encountering: Error: tar xvf exited with 128

With your comment above: #66 (comment)

Turns out I needed to run the npm install command with Powershell rather than GitBash 😅

@bglw -- would you consider adding a note1 in the Installing and running Pagefind section of your website: https://pagefind.app/docs/installation/

In fact, I'm surprised you don't also share (for the new developers not familiar with all the npm and node stuff) that you can run npm install and not just npx 🤔

Footnotes

  1. Something like this: If you see an Error: tar xvf exited with 128 during installation, try using Powershell ❤️

from pagefind.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.