'Getting a TypError saying that my exported function is not a function with nodejs

My goal is to create a discord bot that plays Spotify music, but when I run the function that plays music it gives me the error:

TypeError: playSong is not a function

Here is what is in my api.js:

const playSong = (songName) => {
    spotifyApi.searchTracks(songName)
        .then(data => {
            const track = data.body.tracks.items[0];
            const trackId = track.id;
            spotifyApi.play({
                device_id: '',
                uris: [`spotify:track:${trackId}`]
            });
        })
        .catch(err => {
            console.error(err);

        });
};

module.exports = { playSong };

And here is in my play.js:

const { playSong } = require('../spotify_api/api.js');

let msg = message.content
        let song = msg.replace('!play ', '');

        //creates the audio player
        if (message.content === `!play ${song}`) {
            //VoiceChannel IDs

            //Audio Player
            const player = createAudioPlayer()
            player.on(AudioPlayerStatus.Playing, () => {
                client.message.reply(`Now playing: ${song}`)
                console.log(`Now playing: ${song}`)
            })

            player.on('error', err => {
                console.log(`Error: ${err.message} with resource`)
            })

            //creat and play audio
            player.play(playSong(song)); //This is where I call the function

            //Subscribe the connection to the audio player
            const subscription = connection.subscribe(player)

            if (subscription) {
                //Unsubscribe the subscription
                setTimeout(() => subscription.unsubscribe(), 120000)
            }


        }

I have tried to use other methods I know of but it all comes down to the same TypeError. T_T



Solution 1:[1]

Try to replace

const playSong = () => 

with

function playSong()

Solution 2:[2]

Instead of

module.exports = { playSong };

Use

module.exports.playSong = playSong;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 T1ranexDev
Solution 2 Kai - Kazuya Ito