Using npm in browser?

Hello everyone! I am making a radio and I wanted to know how I can make it show the name of the music with its duration when the music is heard. I’m trying to use npm to do that but the browser doesn’t allow npm.

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

The duration and currentTime are easy enough. But the title of the song is not. That is external, or file metadata. You might be able to use an audio track or label to read from but you would still need to add the title yourself. I guess if you named the files after the song title you might also be able to construct a proper title from that file name and display it.

Use a bundler with a package

I tried with this code using my web page, but it tells me the following “Uncaught ReferenceError: require is not defined at” and from what I was looking for you could use browserify but it still doesn’t work

<h1>Song names</h1>
const icy = require('icy');

const url = '';

icy.get(url, function(res) {
    res.on('metadata', function(data) {
        const parsed = icy.parse(data);

You need to wait for the image to finish uploading before posting. You can edit the post.

We would prefer to see the actual code.

Use the “preformatted text” tool in the editor (</>) to add backticks around the code.

there I have edited it with the code that I try to use in the browser

You can not use icy package on the frontend. It is a Node.js package for a backend server.

Update, I read the docs wrong. It does appear this should work for a front-end client.

Are you actually linking to the browserify bundle?

I get CORS blocked when I try your code, but the bundle does work (no require errors). I tried with a different radio station that had https but it too got blocked. I can’t find something to test it with that actually works.

This one works in the browser without browserify

But again, only the link they give in the docs actually worked for me. Everything else got CORS blocked.

So there is no way to show the name of what is played?