Answer the question
In order to leave comments, you need to log in
How to use FS module inside Electron.Atom\WebPack app?
Hello. There is a task to open a file through input[type=file] to read data from it and write new ones to it.
The first part is easily solved using the HTML5 File Api. But writing new data into it is already problematic.
Used by webpack + react + redux. When all this is built, the result is wrapped using electron.atom to get a desktop application.
To solve the problem, I tried to use fs.writeFile , but then failure awaited me:
The first stone turned out to be:
Cannot resolve module 'fs'
Tried to solve in such images:
target: "node",
---
node: {
global: true,
fs: "empty",
}
---
resolve: {
root: path.join(__dirname),
fallback: path.join(__dirname, 'node_modules'),
modulesDirectories: ['node_modules'],
extensions: ['', '.json', '.js', '.jsx', '.scss', '.png', '.jpg', '.jpeg', '.gif']
},
//В реактовском методе componentDidMount
console.log('fs', fs);
console.log('typeOf', typeof fs.writeFile);
//При клике на кнопку
console.log(fs);
console.log(typeof fs.writeFile);
const path = require('path');
const fs = require('fs');
const webpack = require("webpack");
console.log(fs);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question