title: Updating wifi credentials to wpa_supplicant.conf in Rasberry Pi using Node.js
body: <p>I am trying to provide wifi details to raspberry pi though Bluetooth.</p>
  
  <p>We are adding the wifi credentials to /etc/wpa_supplicant/wpa_supplicant.conf file.</p>
  
  <p>Once I get the credentials I am using nodejs to update the wifi credentials using fs.write(). I am completely overwriting the file. I am providing all the details needed in the file.</p>
  
  <p>But I am getting the following error :</p>
  
  <pre><code>wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
  run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
  Failed to bring up wlan0.
  </code></pre>
  
  <p>But when open the file in nano/vim I see that the file is getting written correctly. Am i missing something? My guess is that it might be the format in which I am writing.</p>
  
  <p>I have an other question:
  What will happen if I keep on appending the file with the wifi credentials, instead of overwriting it?</p>
  
  <p>Any help is greatly appreciated?</p>