how i can do about this error?
Closed this issue · 7 comments
- OS: macOS latest
- Browser: chrome latest
- Nuxt version: 3.8.1
- @iconify/tools version - 3.0.7
issue
-
I used the
importDirectory
function in nuxt3 and I get this error in the iconify internal function
-
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>
That function can be used only on server, not in browser. You are trying to use it in browser.
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
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?
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.
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?
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.
Thank you so much!... I wish you the best in everything you do!