maizzle / framework

Quickly build HTML emails with Tailwind CSS.
https://maizzle.com
MIT License
1.24k stars 49 forks source link

`ReferenceError: ReadableStream is not defined` after fresh install #1338

Closed asimpletune closed 2 months ago

asimpletune commented 2 months ago

Hello, I was interested in getting started with maizle, but I ran into an issue when I was following the guide for using the markdown starter https://maizzle.com/starters/markdown. After npx maizzle-create, and following the prompts, I see the following error after running npm run dev (or build).

ReferenceError: ReadableStream is not defined
    at Object.<anonymous> (/Users/spence/Developer/email-templates/node_modules/undici/lib/web/fetch/response.js:542:3)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Module.require (node:internal/modules/cjs/loader:1100:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/Users/spence/Developer/email-templates/node_modules/undici/lib/web/fetch/index.js:11:5)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
cossssmin commented 2 months ago

Thanks for opening the issue, it's a problem with a dependency that unexpectedly published breaking changes from a Release Candidate. The problem you're seeing is because that dependency now requires Node 18.17 or higher.

We need to update Juice, the CSS inlining library, to handle this since that's where cheerio is used, but until then try adding the overrides field in your project's package.json:

{
  "private": true,
  "scripts": {
    "dev": "maizzle serve",
    "build": "maizzle build production"
  },
+  "overrides": {
+    "cheerio": "1.0.0-rc.12"
+  },
  "dependencies": {
    "@maizzle/framework": "latest",
    "front-matter": "^4.0.2",
    "markdown-it-attrs": "^4.1.4",
    "shiki": "^0.14.1",
    "tailwindcss-box-shadow": "^2.0.0",
    "tailwindcss-email-variants": "^2.0.0",
    "tailwindcss-mso": "^1.3.0"
  }
}

It should install the last version of that dependency that worked on Node <18.

asimpletune commented 2 months ago

Thanks for the fast reply @cossssmin, that did the trick.

cossssmin commented 2 months ago

You're welcome, sorry about that it was really unexpected for us too. Working on pinning it in Juice for now until cheerio make a decision and handle it somehow.

cossssmin commented 2 months ago

juice@10.0.1 was released to fix this issue with cheerio, now cheerio@1.0.0-rc.12 should be installed automatically in new projects. Closing as resolved, let me know if you still encounter this issue 👍