Can't save/create files using Store.jsCreate GUID / UUID in JavaScript?How can I upload files asynchronously?Event binding on dynamically created elements?Creating multiline strings in JavaScriptCreating a div element in jQueryHow do I include a JavaScript file in another JavaScript file?What is JSONP, and why was it created?Sql Server 'Saving changes is not permitted' error ► Prevent saving changes that require table re-creationWhat is the difference between --save and --save-dev?App.getPath(“userData”) seems to give the wrong path
Can I lend a small amount of my own money to a bank at the federal funds rate?
Why might one *not* want to use a capo?
Is there an in-universe explanation given to the senior Imperial Navy Officers as to why Darth Vader serves Emperor Palpatine?
Why is the Grievance Studies affair considered to be research requiring IRB approval?
How to say "I only speak one language which is English" in French?
Why doesn't Starship have four landing legs?
Why is there not a willingness from the world to step in between Pakistan and India?
Should I ask for a raise one month before the end of an internship?
What checks exist against overuse of presidential pardons in the USA?
Employing a contractor proving difficult
Why can't I identify major and minor chords?
Can a network vulnerability be exploited locally?
If I said I had $100 when asked, but I actually had $200, would I be lying by omission?
How does attacking during a conversation affect initiative?
RAID0 instead of RAID1 or 5, is this crazy?
Journal published a paper, ignoring my objections as a referee
Term used to describe a person who predicts future outcomes
Number of Fingers for a Math Oriented Race
Defending Castle from Zombies
Normalized Malbolge to Malbolge translator
Is Nikon D500 a good fit for nature and ambient-lighting portraits and occasional other uses?
What ways are there to "PEEK" memory sections in (different) BASIC(s)
How do you say "half the time …, the other half …" in German?
Is the internet in Madagascar faster than in UK?
Can't save/create files using Store.js
Create GUID / UUID in JavaScript?How can I upload files asynchronously?Event binding on dynamically created elements?Creating multiline strings in JavaScriptCreating a div element in jQueryHow do I include a JavaScript file in another JavaScript file?What is JSONP, and why was it created?Sql Server 'Saving changes is not permitted' error ► Prevent saving changes that require table re-creationWhat is the difference between --save and --save-dev?App.getPath(“userData”) seems to give the wrong path
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
So I wanted to save a file on the client storage using Store.js.
I can change the date using store.set
and i can log
it to console to see the change, but then it's supposed to be saved in app data where it's not created.
I tried to get the Path where it's being saved and it's :
C:UsersUSERAppDataRoamingstoma2/Categories.json
I noticed that there is a "/" so I tried :
C:UsersUSERAppDataRoamingstoma2Categories.json
and :C:/Users/USER/AppData/Roaming/stoma2/Categories.json
But all 3 of them didn't work.
This is my Store.js :
const fs = require('browserify-fs');
var fs2 = require('filereader'),Fs2 = new fs2();
const electron = window.require('electron');
const path = require('path');
class Store
constructor(opts)
// This will just return the property on the `data` object
get(key)
return this.data[key];
// ...and this will set it
set(key, val)
this.data[key] = val;
// Wait, I thought using the node.js' synchronous APIs was bad form?
// We're not writing a server so there's not nearly the same IO demand on the process
// Also if we used an async API and our app was quit before the asynchronous write had a chance to complete,
// we might lose that data. Note that in a real app, we would try/catch this.
fs.writeFile(this.path, JSON.stringify(this.data));
function parseDataFile(filePath, data)
// We'll try/catch it in case the file doesn't exist yet, which will be the case on the first application run.
// `fs.readFileSync` will return a JSON string which we then parse into a Javascript object
try
return JSON.parse(Fs2.readAsDataURL(new File(filePath)));
catch(error)
// if there was some kind of error, return the passed in defaults instead.
return data;
// expose the class
export default Store;
There might be a probleme fith js.writeFile() (well that's the source of probleme).
and this is my call :
//creation
const storeDefCat = new Store(
configName: "Categories",
defaults: require("../data/DefaultCategorie.json")
)
//call for the save
storeDefCat.set('Pizza',id:0,path:storeDefCat.get('Pizza').path);
For now if possible,I might need to find another way to save the file.
And i tried : fs : It doesn't work for me for some reason (I get strange errors that they don't want to be fixed..) .
If anyone has an Idea then please I would be grateful.
javascript reactjs save electron store
add a comment |
So I wanted to save a file on the client storage using Store.js.
I can change the date using store.set
and i can log
it to console to see the change, but then it's supposed to be saved in app data where it's not created.
I tried to get the Path where it's being saved and it's :
C:UsersUSERAppDataRoamingstoma2/Categories.json
I noticed that there is a "/" so I tried :
C:UsersUSERAppDataRoamingstoma2Categories.json
and :C:/Users/USER/AppData/Roaming/stoma2/Categories.json
But all 3 of them didn't work.
This is my Store.js :
const fs = require('browserify-fs');
var fs2 = require('filereader'),Fs2 = new fs2();
const electron = window.require('electron');
const path = require('path');
class Store
constructor(opts)
// This will just return the property on the `data` object
get(key)
return this.data[key];
// ...and this will set it
set(key, val)
this.data[key] = val;
// Wait, I thought using the node.js' synchronous APIs was bad form?
// We're not writing a server so there's not nearly the same IO demand on the process
// Also if we used an async API and our app was quit before the asynchronous write had a chance to complete,
// we might lose that data. Note that in a real app, we would try/catch this.
fs.writeFile(this.path, JSON.stringify(this.data));
function parseDataFile(filePath, data)
// We'll try/catch it in case the file doesn't exist yet, which will be the case on the first application run.
// `fs.readFileSync` will return a JSON string which we then parse into a Javascript object
try
return JSON.parse(Fs2.readAsDataURL(new File(filePath)));
catch(error)
// if there was some kind of error, return the passed in defaults instead.
return data;
// expose the class
export default Store;
There might be a probleme fith js.writeFile() (well that's the source of probleme).
and this is my call :
//creation
const storeDefCat = new Store(
configName: "Categories",
defaults: require("../data/DefaultCategorie.json")
)
//call for the save
storeDefCat.set('Pizza',id:0,path:storeDefCat.get('Pizza').path);
For now if possible,I might need to find another way to save the file.
And i tried : fs : It doesn't work for me for some reason (I get strange errors that they don't want to be fixed..) .
If anyone has an Idea then please I would be grateful.
javascript reactjs save electron store
You are cutting and pasting code without understanding it. Read through that tutorial link I posted yesterday again.
– No Grabbing
Mar 27 at 23:46
It's not am not understanding it, When I tried it with normal fs api I get Strange errors abouts functions not existinf, so I usedbrowserify-fs
to counter the errors but that doesn't seem to solve the probleme. (TypeError: fs.writeFileSync is not a function)
– Med-Amine Benyettou
Mar 28 at 8:49
add a comment |
So I wanted to save a file on the client storage using Store.js.
I can change the date using store.set
and i can log
it to console to see the change, but then it's supposed to be saved in app data where it's not created.
I tried to get the Path where it's being saved and it's :
C:UsersUSERAppDataRoamingstoma2/Categories.json
I noticed that there is a "/" so I tried :
C:UsersUSERAppDataRoamingstoma2Categories.json
and :C:/Users/USER/AppData/Roaming/stoma2/Categories.json
But all 3 of them didn't work.
This is my Store.js :
const fs = require('browserify-fs');
var fs2 = require('filereader'),Fs2 = new fs2();
const electron = window.require('electron');
const path = require('path');
class Store
constructor(opts)
// This will just return the property on the `data` object
get(key)
return this.data[key];
// ...and this will set it
set(key, val)
this.data[key] = val;
// Wait, I thought using the node.js' synchronous APIs was bad form?
// We're not writing a server so there's not nearly the same IO demand on the process
// Also if we used an async API and our app was quit before the asynchronous write had a chance to complete,
// we might lose that data. Note that in a real app, we would try/catch this.
fs.writeFile(this.path, JSON.stringify(this.data));
function parseDataFile(filePath, data)
// We'll try/catch it in case the file doesn't exist yet, which will be the case on the first application run.
// `fs.readFileSync` will return a JSON string which we then parse into a Javascript object
try
return JSON.parse(Fs2.readAsDataURL(new File(filePath)));
catch(error)
// if there was some kind of error, return the passed in defaults instead.
return data;
// expose the class
export default Store;
There might be a probleme fith js.writeFile() (well that's the source of probleme).
and this is my call :
//creation
const storeDefCat = new Store(
configName: "Categories",
defaults: require("../data/DefaultCategorie.json")
)
//call for the save
storeDefCat.set('Pizza',id:0,path:storeDefCat.get('Pizza').path);
For now if possible,I might need to find another way to save the file.
And i tried : fs : It doesn't work for me for some reason (I get strange errors that they don't want to be fixed..) .
If anyone has an Idea then please I would be grateful.
javascript reactjs save electron store
So I wanted to save a file on the client storage using Store.js.
I can change the date using store.set
and i can log
it to console to see the change, but then it's supposed to be saved in app data where it's not created.
I tried to get the Path where it's being saved and it's :
C:UsersUSERAppDataRoamingstoma2/Categories.json
I noticed that there is a "/" so I tried :
C:UsersUSERAppDataRoamingstoma2Categories.json
and :C:/Users/USER/AppData/Roaming/stoma2/Categories.json
But all 3 of them didn't work.
This is my Store.js :
const fs = require('browserify-fs');
var fs2 = require('filereader'),Fs2 = new fs2();
const electron = window.require('electron');
const path = require('path');
class Store
constructor(opts)
// This will just return the property on the `data` object
get(key)
return this.data[key];
// ...and this will set it
set(key, val)
this.data[key] = val;
// Wait, I thought using the node.js' synchronous APIs was bad form?
// We're not writing a server so there's not nearly the same IO demand on the process
// Also if we used an async API and our app was quit before the asynchronous write had a chance to complete,
// we might lose that data. Note that in a real app, we would try/catch this.
fs.writeFile(this.path, JSON.stringify(this.data));
function parseDataFile(filePath, data)
// We'll try/catch it in case the file doesn't exist yet, which will be the case on the first application run.
// `fs.readFileSync` will return a JSON string which we then parse into a Javascript object
try
return JSON.parse(Fs2.readAsDataURL(new File(filePath)));
catch(error)
// if there was some kind of error, return the passed in defaults instead.
return data;
// expose the class
export default Store;
There might be a probleme fith js.writeFile() (well that's the source of probleme).
and this is my call :
//creation
const storeDefCat = new Store(
configName: "Categories",
defaults: require("../data/DefaultCategorie.json")
)
//call for the save
storeDefCat.set('Pizza',id:0,path:storeDefCat.get('Pizza').path);
For now if possible,I might need to find another way to save the file.
And i tried : fs : It doesn't work for me for some reason (I get strange errors that they don't want to be fixed..) .
If anyone has an Idea then please I would be grateful.
javascript reactjs save electron store
javascript reactjs save electron store
asked Mar 27 at 21:19
Med-Amine BenyettouMed-Amine Benyettou
786 bronze badges
786 bronze badges
You are cutting and pasting code without understanding it. Read through that tutorial link I posted yesterday again.
– No Grabbing
Mar 27 at 23:46
It's not am not understanding it, When I tried it with normal fs api I get Strange errors abouts functions not existinf, so I usedbrowserify-fs
to counter the errors but that doesn't seem to solve the probleme. (TypeError: fs.writeFileSync is not a function)
– Med-Amine Benyettou
Mar 28 at 8:49
add a comment |
You are cutting and pasting code without understanding it. Read through that tutorial link I posted yesterday again.
– No Grabbing
Mar 27 at 23:46
It's not am not understanding it, When I tried it with normal fs api I get Strange errors abouts functions not existinf, so I usedbrowserify-fs
to counter the errors but that doesn't seem to solve the probleme. (TypeError: fs.writeFileSync is not a function)
– Med-Amine Benyettou
Mar 28 at 8:49
You are cutting and pasting code without understanding it. Read through that tutorial link I posted yesterday again.
– No Grabbing
Mar 27 at 23:46
You are cutting and pasting code without understanding it. Read through that tutorial link I posted yesterday again.
– No Grabbing
Mar 27 at 23:46
It's not am not understanding it, When I tried it with normal fs api I get Strange errors abouts functions not existinf, so I used
browserify-fs
to counter the errors but that doesn't seem to solve the probleme. (TypeError: fs.writeFileSync is not a function)– Med-Amine Benyettou
Mar 28 at 8:49
It's not am not understanding it, When I tried it with normal fs api I get Strange errors abouts functions not existinf, so I used
browserify-fs
to counter the errors but that doesn't seem to solve the probleme. (TypeError: fs.writeFileSync is not a function)– Med-Amine Benyettou
Mar 28 at 8:49
add a comment |
1 Answer
1
active
oldest
votes
So I managed to fix the probleme, Why fs was sending me errors about undefined functions?Why file wasn't getting created ? It has NOTHING to do with the code it self, but the imports...
To clearify, I was using :
const fs = require('fs');
And the solution is to make it like :
const fs = window.require('fs');
Just adding window.
fixed all the problems .Since it's my first time using electron I wasn't used to import from the window
but it seems it's necessary.And more over...There was no posts saying this is the fix.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386615%2fcant-save-create-files-using-store-js%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
So I managed to fix the probleme, Why fs was sending me errors about undefined functions?Why file wasn't getting created ? It has NOTHING to do with the code it self, but the imports...
To clearify, I was using :
const fs = require('fs');
And the solution is to make it like :
const fs = window.require('fs');
Just adding window.
fixed all the problems .Since it's my first time using electron I wasn't used to import from the window
but it seems it's necessary.And more over...There was no posts saying this is the fix.
add a comment |
So I managed to fix the probleme, Why fs was sending me errors about undefined functions?Why file wasn't getting created ? It has NOTHING to do with the code it self, but the imports...
To clearify, I was using :
const fs = require('fs');
And the solution is to make it like :
const fs = window.require('fs');
Just adding window.
fixed all the problems .Since it's my first time using electron I wasn't used to import from the window
but it seems it's necessary.And more over...There was no posts saying this is the fix.
add a comment |
So I managed to fix the probleme, Why fs was sending me errors about undefined functions?Why file wasn't getting created ? It has NOTHING to do with the code it self, but the imports...
To clearify, I was using :
const fs = require('fs');
And the solution is to make it like :
const fs = window.require('fs');
Just adding window.
fixed all the problems .Since it's my first time using electron I wasn't used to import from the window
but it seems it's necessary.And more over...There was no posts saying this is the fix.
So I managed to fix the probleme, Why fs was sending me errors about undefined functions?Why file wasn't getting created ? It has NOTHING to do with the code it self, but the imports...
To clearify, I was using :
const fs = require('fs');
And the solution is to make it like :
const fs = window.require('fs');
Just adding window.
fixed all the problems .Since it's my first time using electron I wasn't used to import from the window
but it seems it's necessary.And more over...There was no posts saying this is the fix.
answered Mar 28 at 9:08
Med-Amine BenyettouMed-Amine Benyettou
786 bronze badges
786 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386615%2fcant-save-create-files-using-store-js%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You are cutting and pasting code without understanding it. Read through that tutorial link I posted yesterday again.
– No Grabbing
Mar 27 at 23:46
It's not am not understanding it, When I tried it with normal fs api I get Strange errors abouts functions not existinf, so I used
browserify-fs
to counter the errors but that doesn't seem to solve the probleme. (TypeError: fs.writeFileSync is not a function)– Med-Amine Benyettou
Mar 28 at 8:49