Retain files across deployments Node.js RRS feed

  • Question

  • I have node.js running on Windows IOT raspberry pi. The basic plan is to store temperature data etc locally on the rpi from local sensors and serve up the data via node.js.  It all works reasonably well but I haven't been able to find a location to store the data in a persistent manner.  I guess redeploying updates via visual studio, as I change the code wipes out the directory structure on the rpi and rebuilds it so my data files disappear. 

    Any ideas where can I store data files that I want persisted across deployments?



    Saturday, December 10, 2016 11:32 PM

All replies

  • Hi Jim,

    There are a number of threads on storing data to a USB drive. Would that work for you?



    Sunday, December 11, 2016 12:07 AM
  • Hi IoTGirl,

    I did read through some of the threads on storing to the USB drive, but it wasn't clear if that was relevant for my node.js app.  Basically I need a file path that I can feed to netdb (sql like db in javascript) since it manages a simple database running under node.js.  I have looked at Windows.Storage.ApplicationData.current.localFolder which just points to my installation directory.  From what I can tell reading the docs, I can't write outside of my sandbox - namely AppData, LocalCache, LocalState, but all of these can disappear from time to time on a redeploy.  Would looking at the threads on storing to the USB drive give me a file path that I could use outside of the above mentioned directories?


    Sunday, December 11, 2016 12:17 AM
  • Hi IotGirl,

    I have managed to create a file in the PicturesLibrary.  I added
     <uap:Capability Name="picturesLibrary"/>
    to appxmanifest and then use the following code to open a file there:

    var uwp = require('uwp');
            'databasedata.db', Windows.Storage.CreationCollisionOption.FailifExists)
            function (file) {
                uwp.close(); // all async operations are completed, release uwp
                db = new Datastore({ filename: dbFileName, autoload: true });
            function (error) {
                console.error('error', error);
                uwp.close(); // all async operations are completed, release uwp
    This code does create a file in the c:\data\users\defaultaccount\pictures directory.  However I cannot use that path
    (dbFileName = 'c:\\data\\users\\defaultaccount\\pictures\\databasedata.db')
    in a call to nedb DataStore to have it open that file. I get an error message =
    "EPERM: operation not permitted, open 'c:\\data\\users\\defaultaccount\\pictures\\databasedata.db'"

    Am I missing something, or is it simply not possible to open a file with its full url this way?


    • Edited by Jim198 Sunday, December 11, 2016 6:58 PM
    Sunday, December 11, 2016 6:58 PM
  • Can the npm module fs open files in the pictures directory through a full path name?

    Is there anyway to deploy code to the rpi without running the risk of wiping out the directory structure on the rpi (which deletes the files I want to retain)? 


    Thursday, December 15, 2016 4:09 AM