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

how i can do about this error? #38

Closed
yongho0605 opened this issue Dec 7, 2023 · 7 comments
Closed

how i can do about this error? #38

yongho0605 opened this issue Dec 7, 2023 · 7 comments

Comments

@yongho0605
Copy link

  • OS: macOS latest
  • Browser: chrome latest
  • Nuxt version: 3.8.1
  • @iconify/tools version - 3.0.7

issue

  1. I used the importDirectory function in nuxt3 and I get this error in the iconify internal function
    스크린샷 2023-12-07 오후 6 03 13

  2. so, Below is the part that uses importDirectory

<script setup>
import { importDirectory } from '@iconify/tools'

const iconSet = await importDirectory('../assets/icons', {
  prefix: 'datamaker'
})
console.log(iconSet)
</script>
  1. In the terminal, you'll get an error like this
    스크린샷 2023-12-07 오후 6 05 36
@cyberalien
Copy link
Member

That function can be used only on server, not in browser. You are trying to use it in browser.

@yongho0605
Copy link
Author

That function can be used only on server, not in browser. You are trying to use it in browser.

oh!... i see! thanks for your answer

@yongho0605
Copy link
Author

That function can be used only on server, not in browser. You are trying to use it in browser.

Oh, sorry!!! Is the server you're referring to the backend?

@cyberalien
Copy link
Member

Yes. You are trying to scan a directory, that's a file system function. Browser cannot do that.

This package is designed to work only in Node.js environment (also I tried to make it work in Bun too, but some dependencies don't work with it yet). It is not for browser.

@yongho0605
Copy link
Author

yongho0605 commented Dec 7, 2023

Yes. You are trying to scan a directory, that's a file system function. Browser cannot do that.

This package is designed to work only in Node.js environment (also I tried to make it work in Bun too, but some dependencies don't work with it yet). It is not for browser.

so, do you know how I can register the icons in the current project folder ../assets/icons with iconifyJson or use them as iconized icons?

@cyberalien
Copy link
Member

You need to run that import script separately to generate file, write that file, then use that file in your project. Do not bundle script that imports it.

@yongho0605
Copy link
Author

Thank you so much!... I wish you the best in everything you do!

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

No branches or pull requests

2 participants