natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
1.09k stars 59 forks source link

[vite] ..Failed to import "astro-icon" #234

Closed FroggieStick closed 2 months ago

FroggieStick commented 2 months ago

What version of astro-icon are you using?

v1.1.0

Astro Info

[vite] Error when evaluating SSR module /home/rayout/thepond/thePond/astro.config.mjs: failed to import "astro-icon"
|- file:///home/rayout/thepond/thePond/node_modules/.pnpm/@iconify+tools@3.0.7/node_modules/@iconify/tools/lib/svg/index.mjs:1
import cheerio from 'cheerio';
       ^^^^^^^
SyntaxError: The requested module 'cheerio' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:171:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:254:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:482:26)
    at async nodeImport (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52942:15)
    at async ssrImport (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52800:16)
    at async eval (/home/rayout/thepond/thePond/astro.config.mjs:7:31)
    at async instantiateModule (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52858:5)

[astro] Unable to load your Astro config

The requested module 'cheerio' does not provide an export named 'default'
  Stack trace:
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:171:21)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:482:26)
    at async ssrImport (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52800:16)
    at async instantiateModule (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52858:5)
 ELIFECYCLE  Command failed with exit code 1.

If this issue only occurs in one browser, which browser is a problem?

Chrome, Firefox

Describe the Bug

I keep getting this error when trying to run pnpm dev

[vite] Error when evaluating SSR module /home/rayout/thepond/thePond/astro.config.mjs: failed to import "astro-icon"
|- file:///home/rayout/thepond/thePond/node_modules/.pnpm/@iconify+tools@3.0.7/node_modules/@iconify/tools/lib/svg/index.mjs:1
import cheerio from 'cheerio';
       ^^^^^^^
SyntaxError: The requested module 'cheerio' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:171:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:254:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:482:26)
    at async nodeImport (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52942:15)
    at async ssrImport (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52800:16)
    at async eval (/home/rayout/thepond/thePond/astro.config.mjs:7:31)
    at async instantiateModule (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52858:5)

[astro] Unable to load your Astro config

The requested module 'cheerio' does not provide an export named 'default'
  Stack trace:
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:171:21)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:482:26)
    at async ssrImport (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52800:16)
    at async instantiateModule (file:///home/rayout/thepond/thePond/node_modules/.pnpm/vite@5.4.1_@types+node@22.3.0/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:52858:5)
 ELIFECYCLE  Command failed with exit code 1.

Here is my files to show it is setup correctly i believe. astro.config.mjs

import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import sitemap from '@astrojs/sitemap';
import tailwind from "@astrojs/tailwind";
import icon from 'astro-icon';

// https://astro.build/config
export default defineConfig({
  site: 'https://example.com',
  integrations: [mdx(), sitemap(), tailwind(), icon()],
});

packages

{
  "name": "thepond",
  "type": "module",
  "version": "0.0.1",
  "scripts": {
    "dev": "astro dev",
    "start": "astro dev",
    "build": "astro check && astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
  "dependencies": {
    "@astrojs/check": "^0.9.2",
    "@astrojs/mdx": "^3.1.3",
    "@astrojs/rss": "^4.0.7",
    "@astrojs/sitemap": "^3.1.6",
    "@astrojs/tailwind": "^5.1.0",
    "@fortawesome/fontawesome-free": "^6.6.0",
    "@iconify/tools": "^4.0.5",
    "astro": "^4.14.0",
    "astro-icon": "^1.1.0",
    "cheerio": "^1.0.0",
    "typescript": "^5.5.4"
  },
  "devDependencies": {
    "tailwindcss": "^3.4.10"
  }
}

Nav.astro Component being used

---
import { Icon } from 'astro-icon/components';

---

<nav aria-label="Primary">
  <div class="navbar">
    <a href="/" class="frog" aria-label="Go home">
        <Icon name="frog" width={60} />
    </a>
    <ul>
      <!-- List items go here -->
    </ul>
  </div>
</nav>

I have uninstalled astro-icon, ive reinstalled all modules atleast twice. I have deleted .cache I have deleted node_modules and rebuilt with pnpm install atleast twice.

Removeing the astro-icons import in the astro.config.mjs file allows to me run pnpm dev dev normally with no issues.

Here is a picture of my file structure to show the file is indeed in there

image

What's the expected result?

Dev should run. unable to run Dev environment.

Link to Minimal Reproducible Example

no idea what this is

n1ghthouse commented 2 months ago

Is a replication of this https://github.com/natemoo-re/astro-icon/issues/231, still is an issue right now.

FroggieStick commented 2 months ago

ahh. Thank you. I must suck at searching because i looked for similar problems and I guess i over looked it. Thank you. Ill close this then.

FroggieStick commented 2 months ago

Is a replication of this #231, still is an issue right now.