astro-icon icon indicating copy to clipboard operation
astro-icon copied to clipboard

Error when evaluating SSR module "astro-icon"

Open jjjrmy opened this issue 1 year ago β€’ 24 comments

What version of astro-icon are you using?

v1.1.0

Astro Info

Astro                    v4.13.2
Node                     v18.18.0
System                   macOS (arm64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind
                         @astrojs/react
                         astro-auth

[!NOTE]
I had to take out astro-icon Integration or it won't even run the command

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

Every

Describe the Bug

7:28:38 PM [vite] Error when evaluating SSR module /Users/***/Sites/***/astro.config.mjs: failed to import "astro-icon"
|- file:///Users/***/Sites/***/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:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190: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:124:21)

What's the expected result?

It should work

Link to Minimal Reproducible Example

I was not able to recreate it on StackBlitz, but doing

npm create astro@latest
npx astro add astro-icon
npm run dev

It gives me the same error

jjjrmy avatar Aug 09 '24 23:08 jjjrmy

I just started hitting this as well. The Astro build command is working fine, but I have a GitHub Action that runs vitests that started failing this afternoon with this error.

richklein-wf avatar Aug 10 '24 01:08 richklein-wf

It has something to do with the latest release of Cheerio https://github.com/cheeriojs/cheerio/releases/tag/v1.0.0 It was tagged 6 hours ago. This seems more like an issue with @iconify/tools

jjjrmy avatar Aug 10 '24 01:08 jjjrmy

Facing this as well πŸ‘πŸ½

manuraj17 avatar Aug 10 '24 03:08 manuraj17

Not sure how safe it is, but this worked for me (I'm just learning astro at this moment): I added this to the package.json and installed dependencies, "overrides": { "astro-icon": { "cheerio": "1.0.0-rc.12" } }

Bran-mf avatar Aug 10 '24 05:08 Bran-mf

Not sure how safe it is, but this worked for me (I'm just learning astro at this moment): I added this to the package.json and installed dependencies, "overrides": { "astro-icon": { "cheerio": "1.0.0-rc.12" } }

Came to comment this.

Works as a temporary solution, will use this until they get fixed.

manuraj17 avatar Aug 10 '24 05:08 manuraj17

Another way to solve it temporarily is to use resolutions in package.json (I struggled to get the overrides thing to work in a monorepo):

"resolutions": { "cheerio": "1.0.0-rc.12" }

smorgrav avatar Aug 10 '24 06:08 smorgrav

This problem is already solved in @iconify/tools version 4. Below overrides worked for me, and I think it is the better solution.

  "overrides": {
    "astro-icon": {
      "@iconify/tools": "^4.0.0"
    }
  }

Lich496 avatar Aug 11 '24 05:08 Lich496

It worked for me by installing the latest version, npm install @iconify/tools --save

gilbertoxdev avatar Aug 11 '24 07:08 gilbertoxdev

I still get an error without:

"resolutions": { "cheerio": "1.0.0-rc.12" }

adnansmajlovic avatar Aug 11 '24 10:08 adnansmajlovic

@iconify/tools A new revised version 4.0.5 has been released

https://github.com/iconify/tools/commit/3d8d54b7dc36bf40526abaffcc12022c6d636eed

EveSunMaple avatar Aug 11 '24 13:08 EveSunMaple

I'm having the same issue.

ameneses67 avatar Aug 11 '24 19:08 ameneses67

I still get an error without:

"resolutions": { "cheerio": "1.0.0-rc.12" }

Same here. It did not work by any other way...

rderimay avatar Aug 12 '24 10:08 rderimay

@rderimay @adnansmajlovic If you added the @iconify/tools override, don't forget to run npm install again.

Stretsh avatar Aug 12 '24 11:08 Stretsh

@rderimay @adnansmajlovic If you added the @iconify/tools override, don't forget to run npm install again.

yes sure. Did it. Event deleted the node_modules folder to be sure…

rderimay avatar Aug 12 '24 11:08 rderimay

On pnpm I had to do this instead

  "pnpm": {
    "overrides": {
      "@iconify/tools": "^4.0.5"
    }
  }

VisualEhrmanntraut avatar Aug 12 '24 11:08 VisualEhrmanntraut

On pnpm I had to do this instead

  "pnpm": {
    "overrides": {
      "@iconify/tools": "^4.0.5"
    }
  }

Thanks! πŸ™πŸ» This is why it did not work as I am using pnpm. (ping @Stretsh)

rderimay avatar Aug 12 '24 11:08 rderimay

still not fixed, astro still uses version 3.0.7 and even if you change the version to 4.0.5 I still get the error with cheerio...

iEscapedVim avatar Aug 12 '24 20:08 iEscapedVim

For me it worked fine after using that override in my package.json and then running pnpm up --latest.

VisualEhrmanntraut avatar Aug 12 '24 20:08 VisualEhrmanntraut

On pnpm I had to do this instead

  "pnpm": {
    "overrides": {
      "@iconify/tools": "^4.0.5"
    }
  }

Thanks! πŸ™πŸ» This is why it did not work as I am using pnpm. (ping @Stretsh)

Thanks The issue is solved now

sreejithkalarikkal avatar Aug 13 '24 06:08 sreejithkalarikkal

"overrides": { "astro-icon": { "@iconify/tools": "^4.0.0" } }

Thanks The issue is solved now

yangjuzi avatar Aug 13 '24 15:08 yangjuzi

This problem is already solved in @iconify/tools version 4. Below overrides worked for me, and I think it is the better solution.

  "overrides": {
    "astro-icon": {
      "@iconify/tools": "^4.0.0"
    }
  }

This worked for me. Amazing thanks!

sukantg avatar Aug 14 '24 13:08 sukantg

On pnpm I had to do this instead

  "pnpm": {
    "overrides": {
      "@iconify/tools": "^4.0.5"
    }
  }

wow,thank you ,use code fix the bug

DerickIT avatar Aug 14 '24 15:08 DerickIT

Facing same error and npm install @iconify/tools --save dint work for me

snimavat avatar Aug 15 '24 13:08 snimavat

Seem to be fixed in [email protected] by https://github.com/natemoo-re/astro-icon/pull/230 bumping to @iconify/tools@^4.0.4

At least i don't have build issues anymore on my side

Chrissdroid avatar Aug 17 '24 13:08 Chrissdroid

I believe this is resolved. Closing.

stramel avatar Oct 22 '24 06:10 stramel