title: Make Discord Bot for node.js JSON.parse() error : undefined:1
body: <p>I want to make Discord Bot.</p>
  
  <p>I use Node.js and Discord api.</p>
  
  <p><strong>my error :</strong></p>
  
  <pre><code>C:\----\----\Desktop\SiiNaBot&gt;node app.js
  undefined:1
  SyntaxError: Unexpected end of JSON input
  at JSON.parse (&lt;anonymous&gt;)
  at Object.&lt;anonymous&gt; (C:\Users\Lin\Desktop\SiiNaBot\app.js:7:21)
  at Module._compile (module.js:573:30)
  at Object.Module._extensions..js (module.js:584:10)
  at Module.load (module.js:507:32)
  at tryModuleLoad (module.js:470:12)
  at Function.Module._load (module.js:462:3)
  at Function.Module.runMain (module.js:609:10)
  at startup (bootstrap_node.js:158:16)
  at bootstrap_node.js:598:3
  </code></pre>
  
  <p><strong>my cord :</strong> </p>
  
  <pre><code>//Calling the pakage
  const Discord = require('discord.js');
  const bot = new Discord.Client();
  const fs = require('fs');
  
  // JSON Files
  let userData = JSON.parse(fs.readFileSync('Storage/userData.json', 'utf8')); // This calls the JSON file.
  
  //Listener Event : Message Received ( This wiil run every time a message is recived)
  bot.on('message', message =&gt; {
    //Variables
    let sender = message.author; // The person who sent th message
    let msg = message.content.toUpperCase(); // Takes the message, and makes it all uppercase
    let prefix = '&gt;' // The test before commands, you can set this to what ever you want
  
    //Event
    if(!userData[sender.id + message.guild.id]) userData[sender.id + message.guild.id] = {} // This creates a json file for their user + guild, if one is not made already.
    if(!userData[sender.id + message.guild.id].money) userData[sender.id + message.guild.id].money = 1000; // This creates a money object for them if they start out with, you can change this to whatever you want.
  
    fs.writeFile('Storage/userData.json', JSON.stringify(userData), (err) =&gt; { 
  //This writes the changes we just made to the JSON file.
      if (err) console.error(err);
    })
    // Commends
  
    //Ping
    if (msg === prefix + 'PING'){
      message.channel.send('Pong!') // Sends a message to the chanel, with the contens: "Pong!"
    }
  
  
  
  
  })
  
  // This code runs when the bot turns on
  bot.on('ready', () =&gt; {
    console.log('Economy Launched...')
  })
  
  
  // Login
  
  bot.login('I`ll write code my bot token'); 
  //Don`t let people see this code, people can control your bot, including the servers your bot has admin on.
  </code></pre>
  
  <p><strong>My Folder</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/vIOSN.png" rel="nofollow noreferrer">Structure of my folder here</a></p>
  
  <p>I think this error is this line </p>
  
  <p><strong>let userData = JSON.parse(fs.readFileSync('Storage/userData.json', 'utf8'))</strong></p>
  
  <p>and...</p>
  
  <p><strong>fs.writeFile('Storage/userData.json', JSON.stringify(userData), (err) => { //This writes the changes we just made to the JSON file.
      if (err) console.error(err);
    })</strong></p>
  
  <p>this line. but i don`t know how can i fix this cord.</p>
  
  <p>How can i do?</p>