onmax / astro-single-file

Integration made for Astro that allows to build HTML & CSS in a single file
https://www.npmjs.com/package/astro-single-file
15 stars 2 forks source link

Cannot find package 'html-minifier-terser' imported from .../astro-single-file/index.js #1

Open jChapman opened 1 year ago

jChapman commented 1 year ago

After running astro add astro-single-file and attempting to run dev or build I get the following error (missing dependency?)

08:48:51 PM [astro] Unable to load /home/projects/nbwiabryp.github/astro.config.mjs

 error   Cannot find package 'html-minifier-terser' imported from /home/projects/nbwiabryp.github/node_modules/astro-single-file/index.js
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'html-minifier-terser' imported from /home/projects/nbwiabryp.github/node_modules/astro-single-file/index.js
    at InternalError.get (https://nbwiabryp--github.w.staticblitz.com/blitz.912cb019f8b62040b90085f00ac69aca69f51e29.js:6:292489)
    at instantiateModule (file:///home/projects/nbwiabryp.github/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:53495:15)

Did it from scratch on stack blitz and ran into the same issue, here's the full log of what I ran (also double checked that the astro config file did get updated)

~/projects/nbwiabryp.github 2s
❯ astro add astro-single-file
⚠ astro-single-file is not an official Astro package. Use at your own risk!
✔ Continue? … yes
✔ Resolving with third party packages...

  Astro will run the following command:
  If you skip this step, you can always run it yourself later

 ╭────────────────────────────────╮
 │ npm install astro-single-file  │
 ╰────────────────────────────────╯

✔ Continue? … yes
✔ Installing dependencies...

  Astro will make the following changes to your config file:

 ╭ astro.config.mjs ─────────────────────────────╮
 │ import { defineConfig } from 'astro/config';  │
 │                                               │
 │ // https://astro.build/config                 │
 │ import singleFile from "astro-single-file";   │
 │                                               │
 │ // https://astro.build/config                 │
 │ export default defineConfig({                 │
 │   integrations: [singleFile()]                │
 │ });                                           │
 ╰───────────────────────────────────────────────╯

✔ Continue? … yes

   success  Added the following integration to your project:
  - astro-single-file

~/projects/nbwiabryp.github 16s
❯ astro dev
08:48:51 PM [astro] Unable to load /home/projects/nbwiabryp.github/astro.config.mjs

 error   Cannot find package 'html-minifier-terser' imported from /home/projects/nbwiabryp.github/node_modules/astro-single-file/index.js
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'html-minifier-terser' imported from /home/projects/nbwiabryp.github/node_modules/astro-single-file/index.js
    at InternalError.get (https://nbwiabryp--github.w.staticblitz.com/blitz.912cb019f8b62040b90085f00ac69aca69f51e29.js:6:292489)
    at instantiateModule (file:///home/projects/nbwiabryp.github/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:53495:15)
tobias-edwards commented 1 year ago

Like you, I installed html-minifier-terser separately and it seems to work on macOS.

This plugin does only seem to work for single pages only i.e. a website with a nested route will not inline the CSS correctly. Astro intend to support inlining CSS natively: https://github.com/withastro/roadmap/issues/556