пытаюсь делать так:
var fs = require('fs');
fs.writeFile("./test.txt", "Hey there!", function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
но вылетает такая ошибка:
Uncaught TypeError: fs.writeFile is not a function
как исправить?
package.json
{
"name": "backend-with-webpack",
"main": "index.js",
"scripts": {
"test": "echo \"Error\" ",
"build": "webpack src/js/app.js dist/bundle.js",
"start": "serve dist"
},
"devDependencies": {
"babel-plugin-transform-regenerator": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"webpack": "^2.7.0",
"fs": "^0.0.1-security"
},
"dependencies": {
"@babel/polyfill": "^7.12.1",
"babel": "^6.23.0",
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"browserify-fs": "^1.0.0",
"fs": "^0.0.1-security",
"serve": "^12.0.0"
},
"browser": {
"fs": false
}
}