broeker / spacebook

💥 Create fast and simple documentation to explain almost anything. Uses Eleventy, Tailwind 2.0, and Alpine JS with an optional Netlify CMS.
https://spacebook.app
MIT License
301 stars 64 forks source link

Throws an error on MacOs Ventura #45

Open MattArnold opened 1 year ago

MattArnold commented 1 year ago

Describe the bug Everything worked as expected, until I upgraded the MacOS version from Monterey to Ventura. Running npm start in iTerm2 to run the site locally outputs an error:

> eleventy --serve & postcss styles/tailwind.css --o _tmp/style.css --watch

Eleventy fatal error: (more in DEBUG output)
> Error in your Eleventy config file '/Users/____/___/_________________/.eleventy.js'.

`EleventyConfigError` was thrown
> 'darwin-x64' binaries cannot be used on the 'darwin-arm64v8' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'darwin-arm64v8' platform.

Removing the 'node_modules/sharp' directory and running 'npm install', as directed in the error message, changes nothing.

Pushing changes to Netlify still builds the site on the web without errors.

To Reproduce Steps to reproduce the behavior:

  1. Upgrade MacOS from Monterey to Ventura.
  2. In iTerm2, cd to spacebook directory
  3. run npm start

Expected behavior npm start builds the site with its new changes (if any), starts a server locally, and outputs a localhost address to the terminal, with which to see the changes to the site in the browser.

Screenshots

Screenshot 2022-12-14 at 10 45 33 AM

Additional context MacBook Pro 16-inch, 2021, Apple M1 Max, Ventura 13.0.1 iTerm2 3.4.16 using zsh and fig

imacrayon commented 1 year ago

Try deleting package-lock.json and node_modules and then do an npm install. I’ve run into situations like this where things get cached in the lock file.

MattArnold commented 1 year ago

tldr: Update the version of @11ty/eleventy-img.

Having deleted package-lock.json and 'node_modules, runningnpm install` threw a bunch of errors, including:

npm ERR! ERR! sharp Prebuilt libvips 8.10.0 binaries are not yet available for darwin-arm64v8
npm ERR! info sharp Attempting to build from source via node-gyp but this may fail due to the above error
npm ERR! info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies

Going to the website from that link showed me:

Apple M1
Prebuilt sharp and libvips binaries have been provided for macOS on ARM64 since sharp v0.29.0.

package.json does not seem to contain sharp; presumably this is because prebuilt binaries are not Javascript packages. Apparently sharp is included in spacebook through the eleventy-plugin-lazyimages package, in which the Sharp dependency was updated to "sharp": ">=0.29.3" in November 2021 which is later than 0.29.0.

The lazysizes and markdown-it-image-lazysizes dependencies do not seem to bring in sharp, so that's probably not the issue.

Now we come to 11ty/eleventy-img. As soon as I deleted that line from package.json, I was able to npm install without throwing an error. My site started building locally as soon as I went into eleventy.js, commented out const Image = require("@11ty/eleventy-img");, and changed let metadata = await Image( etc to `let metadata = {}'.

I put eleventy.js back the way it was, changed "@11ty/eleventy-img": "^0.5.0", to "@11ty/eleventy-img": "^=2.0.1", in package.json, and the site seems to work well.