Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@vicons/utils 依赖的 css-render 版本太低,在 Nuxt 中会产生 window is not defined 错误 #873

Open
cssmagic opened this issue Aug 23, 2024 · 1 comment

Comments

@cssmagic
Copy link

cssmagic commented Aug 23, 2024

错误

一个 Nuxt 3 项目,在组件或 plugin 中存在以下代码:

import { Icon } from '@vicons/utils'

会得到以下错误:

 ERROR  window is not defined

  at Object.<anonymous> (node_modules/.pnpm/[email protected]/node_modules/css-render/lib/mount.js:8:1)
  at ...

分析

查看引发错误的 css-render/lib/mount.js 的文件,存在 if (window) { ... } 这样的代码。可以确定这个错误确实是由 css-render 这个包引起的。

(到 GitHub 查看 这个文件的最新代码已经修了 “在 Node 环境下报错” 的问题。)

这个包的引入原因如下:

@vicons/utils 0.1.4
└─┬ @xicons/utils 0.1.4
  └── css-render 0.13.9

解决方案

目前 css-render 已经升级到 0.15.x 版本了,但 @vicons/utils 依赖的还是 0.13.x 版本。麻烦作者升级一下依赖 🙏

如果作者实在精力有限的话,给 css-render 发布一个 0.13.x 的 hotfix 版本也行 😭

@transtone
Copy link

直接用 https://unocss.dev/presets/icons 吧,简单方便。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants