You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi.
The readme provides an example of using this library in a web browser via a <script/> tag:
<inputtype="file"><scripttype="module">
import * as id3 from '//unpkg.com/id3js@^2/lib/id3.js';
document
.querySelector('input[type="file"]')
.addEventListener('change', async (e) =>{consttags=awaitid3.fromFile(e.currentTarget.files[0]);// tags now contains v1, v2 and merged tags});
</script>
That's not the most conventional way of using packages in a web browser.
The most conventional one is using a "bundler" like Webpack and importing directly from npm packages.
Example:
import{fromFile}from'id3js'consttags=awaitfromFile(file)// tags now contains v1, v2 and merged tags
But it throws an error:
Module not found: Can't resolve 'fs' in '...\node_modules\id3js\lib'
node_modules/id3js/lib/localReader.js
For some reason, it seems to execute that await import() statement even though I didn't call that specific function called fromPath().
The error happens before calling any function, already at the import level:
import*asId3from'id3js'
I've fixed that in my fork by introducing two separate exports: /browser and /node.
Hi.
The readme provides an example of using this library in a web browser via a
<script/>
tag:That's not the most conventional way of using packages in a web browser.
The most conventional one is using a "bundler" like Webpack and importing directly from npm packages.
Example:
But it throws an error:
So the
main
file of the library looks like this:https://unpkg.com/browse/[email protected]/lib/id3.js
For some reason, it seems to execute that
await import()
statement even though I didn't call that specific function calledfromPath()
.The error happens before calling any function, already at the
import
level:I've fixed that in my fork by introducing two separate exports:
/browser
and/node
.See the updated README:
https://github.com/catamphetamine/id3
It now works in my setup (Webpack).
I've also added a function for getting an album cover image data URL.
The text was updated successfully, but these errors were encountered: