viteastrojs

Error when evaluating SSR module F:\oceanh_workspace\Project\blog-astro\astro.config.mjs: failed to import "astro-icon"


I have an astro website and starting today when I build locally 'astro dev/build' will report the following error.

OS: Windows10
Node version: v20.16.0
Package manager: Pnpm v9.7.0
Astro version: v4.13.1
Error Message:
[vite] Error when evaluating SSR module F:\oceanh_workspace\Project\blog-astro\astro.config.mjs: failed to import "astro-icon" |-file:///F:/oceanh_workspace/Project/blogastro/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:134:21) at async ModuleJob.run (node:internal/modules/esm/module_job:217:5) at async nodeImport (file:///F:/oceanh_workspace/Project/blog-astro/node_modules/.pnpm/vite@5.4.0@types+node@22.2.0_lightningcss@1.25.1_sass@1.77.8_stylus@0.63.0_terser@5.31.5/node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:52928:15) at async ssrImport (file:///F:/oceanh_workspace/Project/blog-astro/node_modules/.pnpm/vite@5.4.0_@types+node@22.2.0_lightningcss@1.25.1_sass@1.77.8_stylus@0.63.0_terser@5.31.5/node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:52786:16) at async eval (F:/oceanh_workspace/Project/blog-astro/astro.config.mjs:10:31) at async instantiateModule (file:///F:/oceanh_workspace/Project/blog-astro/node_modules/.pnpm/vite@5.4.0_@types+node@22.2.0_lightningcss@1.25.1_sass@1.77.8_stylus@0.63.0_terser@5.31.5/node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:52844: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:134:21) at async ModuleLoader.import (node:internal/modules/esm/loader:316:24) at async ssrImport (file:///F:/oceanh_workspace/Project/blog-astro/node_modules/.pnpm/vite@5.4.0@types+node@22.2.0_lightningcss@1.25.1_sass@1.77.8_stylus@0.63.0_terser@5.31.5/node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:52786:16) at async instantiateModule (file:///F:/oceanh_workspace/Project/blog-astro/node_modules/.pnpm/vite@5.4.0_@types+node@22.2.0_lightningcss@1.25.1_sass@1.77.8_stylus@0.63.0_terser@5.31.5/node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:52844:5) ELIFECYCLE  Command failed with exit code 1.

I've tried a lot of ways, like removing node_modules, clearing pnpm's cache, updating dependent versions, and even rolling back the code to previous versions, but nothing has fixed the problem, which drives me crazy.Plz help me.


Solution

  • This problem is solved in @iconify/tools version 4.

    import cheerio from 'cheerio';import * as cheerio from 'cheerio';

    If you are using astro-icon, this issue will also be helpful: https://github.com/natemoo-re/astro-icon/issues/231