jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.06k stars 216 forks source link

BrowserFS not working with webpack #368

Closed jman13378 closed 9 months ago

jman13378 commented 9 months ago

when i dont use configure i get VM1210:5 Uncaught Error: Error: EIO: Initialize BrowserFS with a file system using BrowserFS.initialize(filesystem) when i use configure i get Uncaught TypeError: e is not a function code that uses BFS

const fr = require("browserfs");
fr.configure({ fs: "LocalStorage" });

delete window.localStorage;

window.TwetzelWebPackChunk[5858][3] = fr.BFSRequire("fs");
webpack config ```js const path = require("path"); var { FilerWebpackPlugin } = require("filer/webpack"); const webpack = require("webpack"); module.exports = { resolve: { // Use our versions of Node modules. alias: { fs: "browserfs/dist/shims/fs.js", buffer: "browserfs/dist/shims/buffer.js", path: "browserfs/dist/shims/path.js", processGlobal: "browserfs/dist/shims/process.js", bufferGlobal: "browserfs/dist/shims/bufferGlobal.js", bfsGlobal: require.resolve("browserfs"), }, fallback: { fs: require.resolve("browserify-fs"), stream: require.resolve("stream-browserify"), buffer: require.resolve("buffer"), }, }, entry: "./src/index.js", mode: "production", output: { filename: "main.js", path: path.resolve(__dirname, "dist"), }, plugins: [new webpack.ProvidePlugin({ BrowserFS: "bfsGlobal", process: "processGlobal", Buffer: "bufferGlobal" }), new FilerWebpackPlugin()], }; ```
james-pre commented 9 months ago

@jman13378 Which version of browserfs are you using?

jman13378 commented 9 months ago

idk latest

james-pre commented 9 months ago

If you're using the latest from NPM, it will not have the latest bug fixes and features. Please read Releases and compatibility going forward.

Try building it from source. That should fix the issue:

git clone https://github.com/jvilk/BrowserFS
cd BrowserFS
npm i
npm run build
jman13378 commented 9 months ago

where do i clone it, anywhere, in the root of the project, in the node_modules of the project

james-pre commented 9 months ago

Please clone it in a separate directory. You can then symlink the BrowserFS in node_modules to it.

For example (from your project):

cd ..
git clone https://github.com/jvilk/browserfs
cd browserfs 
npm i
npm run build
cd ../your-project
rm -rf node_modules/browserfs
ln -s ../browserfs node_modules/browserfs
jman13378 commented 9 months ago

now when i run my build command i get this

Error ```diff ERROR in ./node_modules/debug/src/browser.js 226:18-25 Module not found: Error: Can't resolve 'processGlobal' in 'D:\webpack\node_modules\debug\src' @ ./node_modules/socket.io-client/build/cjs/index.js 12:32-48 @ ./src/index.js 47:38-65 ERROR in ./node_modules/filer/lib/async.js 15:15-22 Module not found: Error: Can't resolve 'processGlobal' in 'D:\webpack\node_modules\filer\lib' @ ./node_modules/filer/src/shell/shell.js 5:12-41 @ ./node_modules/filer/src/index.js 11:9-36 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/node_modules/schema-utils/dist/validate.js 133:6-13 Module not found: Error: Can't resolve 'processGlobal' in 'D:\webpack\node_modules\filer\node_modules\schema-utils\dist' @ ./node_modules/filer/node_modules/schema-utils/dist/index.js 9:4-25 @ ./node_modules/filer/src/webpack-plugin/utils.js 1:19-42 @ ./node_modules/filer/src/webpack-plugin/index.js 2:12-30 @ ./node_modules/filer/src/index.js 21:22-49 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/filesystem/implementation.js 707:17-23 Module not found: Error: Can't resolve 'bufferGlobal' in 'D:\webpack\node_modules\filer\src\filesystem' @ ./node_modules/filer/src/filesystem/interface.js 32:13-43 @ ./node_modules/filer/src/index.js 5:14-50 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/filesystem/interface.js 81:9-15 Module not found: Error: Can't resolve 'bufferGlobal' in 'D:\webpack\node_modules\filer\src\filesystem' @ ./node_modules/filer/src/index.js 5:14-50 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/index.js 6:10-16 Module not found: Error: Can't resolve 'bufferGlobal' in 'D:\webpack\node_modules\filer\src' @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/path.js 5:0-7 Module not found: Error: Can't resolve 'processGlobal' in 'D:\webpack\node_modules\filer\src' @ ./node_modules/filer/src/index.js 8:8-28 9:8-28 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/providers/indexeddb.js 61:19-25 Module not found: Error: Can't resolve 'bufferGlobal' in 'D:\webpack\node_modules\filer\src\providers' @ ./node_modules/filer/src/providers/index.js 1:18-43 @ ./node_modules/filer/shims/providers/default.js 1:20-56 @ ./node_modules/filer/shims/fs.js 5:13-34 8:13-43 @ ./node_modules/ejs/lib/ejs.js 48:9-22 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/webpack-plugin/processors.js 4:12-19 Module not found: Error: Can't resolve 'processGlobal' in 'D:\webpack\node_modules\filer\src\webpack-plugin' @ ./node_modules/filer/src/webpack-plugin/index.js 7:27-50 @ ./node_modules/filer/src/index.js 21:22-49 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/path/path.js 25:16-23 Module not found: Error: Can't resolve 'processGlobal' in 'D:\webpack\node_modules\path' @ ./node_modules/filer/src/path.js 12:17-32 @ ./node_modules/filer/src/index.js 8:8-28 9:8-28 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/util/util.js 73:6-13 Module not found: Error: Can't resolve 'processGlobal' in 'D:\webpack\node_modules\util' @ ./node_modules/path/path.js 26:11-26 @ ./node_modules/filer/src/path.js 12:17-32 @ ./node_modules/filer/src/index.js 8:8-28 9:8-28 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/engine.io-client/build/cjs/transports/websocket.js 96:51-57 Module not found: Error: Can't resolve 'bufferGlobal' in 'D:\webpack\node_modules\engine.io-client\build\cjs\transports' @ ./node_modules/engine.io-client/build/cjs/transports/index.js 5:23-48 @ ./node_modules/engine.io-client/build/cjs/index.js 9:17-49 @ ./node_modules/socket.io-client/build/cjs/url.js 7:27-54 @ ./node_modules/socket.io-client/build/cjs/index.js 7:17-36 @ ./src/index.js 47:38-65 ERROR in ./node_modules/ajv-keywords/keywords/instanceof.js Cannot read properties of undefined (reading 'module') @ ./node_modules/ajv-keywords/keywords/index.js 4:16-39 @ ./node_modules/ajv-keywords/index.js 3:15-36 @ ./node_modules/filer/node_modules/schema-utils/dist/validate.js 58:22-45 @ ./node_modules/filer/node_modules/schema-utils/dist/index.js 9:4-25 @ ./node_modules/filer/src/webpack-plugin/utils.js 1:19-42 @ ./node_modules/filer/src/webpack-plugin/index.js 2:12-30 @ ./node_modules/filer/src/index.js 21:22-49 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/debug/src/browser.js Cannot read properties of undefined (reading 'module') @ ./node_modules/socket.io-client/build/cjs/index.js 12:32-48 @ ./src/index.js 47:38-65 ERROR in ./node_modules/filer/lib/async.js Cannot read properties of undefined (reading 'module') @ ./node_modules/filer/src/shell/shell.js 5:12-41 @ ./node_modules/filer/src/index.js 11:9-36 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/node_modules/schema-utils/dist/validate.js Cannot read properties of undefined (reading 'module') @ ./node_modules/filer/node_modules/schema-utils/dist/index.js 9:4-25 @ ./node_modules/filer/src/webpack-plugin/utils.js 1:19-42 @ ./node_modules/filer/src/webpack-plugin/index.js 2:12-30 @ ./node_modules/filer/src/index.js 21:22-49 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/filesystem/implementation.js Cannot read properties of undefined (reading 'module') @ ./node_modules/filer/src/filesystem/interface.js 32:13-43 @ ./node_modules/filer/src/index.js 5:14-50 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/filesystem/interface.js Cannot read properties of undefined (reading 'module') @ ./node_modules/filer/src/index.js 5:14-50 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/index.js Cannot read properties of undefined (reading 'module') @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/path.js Cannot read properties of undefined (reading 'module') @ ./node_modules/filer/src/index.js 8:8-28 9:8-28 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/providers/indexeddb.js Cannot read properties of undefined (reading 'module') @ ./node_modules/filer/src/providers/index.js 1:18-43 @ ./node_modules/filer/shims/providers/default.js 1:20-56 @ ./node_modules/filer/shims/fs.js 5:13-34 8:13-43 @ ./node_modules/ejs/lib/ejs.js 48:9-22 @ ./src/index.js 38:38-52 ERROR in ./node_modules/filer/src/webpack-plugin/processors.js Cannot read properties of undefined (reading 'module') @ ./node_modules/filer/src/webpack-plugin/index.js 7:27-50 @ ./node_modules/filer/src/index.js 21:22-49 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/path/path.js Cannot read properties of undefined (reading 'module') @ ./node_modules/filer/src/path.js 12:17-32 @ ./node_modules/filer/src/index.js 8:8-28 9:8-28 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/util/util.js Cannot read properties of undefined (reading 'module') @ ./node_modules/path/path.js 26:11-26 @ ./node_modules/filer/src/path.js 12:17-32 @ ./node_modules/filer/src/index.js 8:8-28 9:8-28 @ ./node_modules/filer/shims/path.js 1:17-40 @ ./node_modules/ejs/lib/ejs.js 50:11-26 @ ./src/index.js 38:38-52 ERROR in ./node_modules/engine.io-client/build/cjs/transports/websocket.js Cannot read properties of undefined (reading 'module') @ ./node_modules/engine.io-client/build/cjs/transports/index.js 5:23-48 @ ./node_modules/engine.io-client/build/cjs/index.js 9:17-49 @ ./node_modules/socket.io-client/build/cjs/url.js 7:27-54 @ ./node_modules/socket.io-client/build/cjs/index.js 7:17-36 @ ./src/index.js 47:38-65 26 errors have detailed information that is not shown. Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it. webpack 5.88.2 compiled with 26 errors in 9865 ms ```
james-pre commented 9 months ago

I don't see any issues with BrowserFS. What does index.js look like?

I recently removed the various polyfills exported by BrowserFS (path, process, buffer, etc.). The change was made because BrowserFS is not intended to polyfill those APIs. If you need to polyfill them, you can install a polyfill separately. Moreover, the polyfills used (bfs-path, bfs-process, etc.) were old and did not support the standard APIs correctly.

Those polyfills may have defined the missing globalName variables, which would have led to those errors. Regardless, having the index.js code would help me understand the problem better.

jman13378 commented 9 months ago
import _ from "lodash";

window["privateLocalStorage"] = window.localStorage;
delete window.clearInterval;

const Twetzel = {
  /** General Objects */
  5858: {
    /** */ 1: Object,
    /** .*/ 2: Object,
    /** */ 3: Object,
    /** */ 4: Object,
    /** */ 5: Object,
    /** */ 6: Object,
    /** */ 7: Object,
    /** */ 8: Object,
    /** */ 9: Object,
    /** */ 10: Object,
    /** */ 213: Object,
    /** */ 424: Object,
    /** */ 5643: Object,
    /** */ 64353: Object,
  },
  /** Valuables */
  5888: {
    /** */ 565: Object,
    /** */ 56564: Object,
    /** */ 347: Object,
    /** */ 1234: Object,
    /** */ 126: Object,
    /** */ 2454: Object,
  },
};
window["Twetzel"] = Twetzel;

window.Twetzel[5888][565] = window.privateLocalStorage;
delete window.privateLocalStorage;
window.Twetzel[5858][1] = require("ejs");

const fr = require("browserfs");
fr.configure({ fs: "LocalStorage" });

delete window.localStorage;

window.Twetzel[5858][3] = fr.BFSRequire("fs");

window.Twetzel[5858][2] = require("socket.io-client");

window.Twetzel[5888][56564] = window.Twetzel[5858][2]("dashboard.sokobot.info/");
console.log(window.Twetzel);
require("./socket/socket")(window.Twetzel[5888][56564]);

console.log("e");

window["messages"] = document.getElementById("messages");
var form = document.getElementById("form");
//var loginform = document.getElementById("loginf");
//var signupform = document.getElementById("signupf");

var msg = document.getElementById("input");
/*form.addEventListener("submit", function (e) {
  e.preventDefault();

  if (input.value) {
    if (input.value.includes("\\")) {
      input.value = "";
      return;
    }
    let data = JSON.parse(decodeBase64(localStorage.getItem("data")));
    console.log(data);
    socket.emit("chat message", `{"message": "${input.value}", "id": "${data.username}"}`);
    input.value = "";
  }
});*/

/*`
<iframe frameBorder="0" src="login.html" style="
width: 100%;
height: 100%;
position: fixed;
z-index: 1;
"></iframe>`,
*/
james-pre commented 9 months ago

You are getting the errors because you are mixing CommonJS and ESM modules... You will have to use one or the other.

You also appear to be attempting to use DOM/browser APIs while using NPM modules and Node's require. Again, you will have to choose one (or use a bundler, which I recommend).

jman13378 commented 9 months ago

to me it looks like im only using CommonJS modules

james-pre commented 9 months ago

Literally the first line is ESM: import _ from "lodash";

jman13378 commented 9 months ago

that was from webpack i never removed it

james-pre commented 9 months ago

I recently removed the various polyfills exported by BrowserFS (path, process, buffer, etc.). The change was made because BrowserFS is not intended to polyfill those APIs. If you need to polyfill them, you can install a polyfill separately. Moreover, the polyfills used (bfs-path, bfs-process, etc.) were old and did not support the standard APIs correctly.

Those polyfills may have defined the missing globalName variables, which would have led to those errors. Regardless, having the index.js code would help me understand the problem better.

You can't use browserfs shims, as they have been removed. You should use a polyfill.

jman13378 commented 9 months ago

Alright sorry for the late response im now getting this error in the browser console Uncaught TypeError: e is not a function

full error ```diff main.js:2 Uncaught TypeError: e is not a function at main.js:2:323624 at e.Create (main.js:2:245815) at main.js:2:322032 at V (main.js:2:181078) at forEach.t.Create (main.js:2:322004) at a (main.js:2:322620) at fo (main.js:2:322967) at e.configure (main.js:2:323595) at main.js:2:712605 at main.js:2:713077 ```
Code from error: from webpack ```js e.install = function(e) { e.Buffer = t, e.process = a; var r = e.require ? e.require : null; e.require = function(t) { return co(t) || r.apply(null, Array.prototype.slice.call(arguments, 0)) } } , e.registerFileSystem = function(t, e) { so[t] = e } , e.BFSRequire = co, e.initialize = uo, e.configure = function(t, e) { fo(t, (function(t, r) { r ? (uo(r), e()) : e(t) // this was the line of the error } )) } , e.getFileSystem = fo, e.EmscriptenFS = K, e.FileSystem = so, e.Errors = p, e.setImmediate = Ir } ).call(e, r(1), function() { return this }(), r(5)(t), r(6)) ```
james-pre commented 9 months ago

@jman13378

I'm able to build and use BFS fine locally. Are you building from the latest commit or installing from NPM? If your building correctly, you may need to fix your import syntax.

jman13378 commented 9 months ago

i am using

Please clone it in a separate directory. You can then symlink the BrowserFS in node_modules to it.

For example (from your project):

cd ..
git clone https://github.com/jvilk/browserfs
cd browserfs 
npm i
npm run build
cd ../your-project
rm -rf node_modules/browserfs
ln -s ../browserfs node_modules/browserfs
james-pre commented 9 months ago

Can you please get the errors from source? The error message is from the minified code, and does not help me understand the problem. Using a source map would be very helpful

Is there anywhere I can take a look at your code?

jman13378 commented 9 months ago
import _ from "lodash";

window["privateLocalStorage"] = window.localStorage;
delete window.clearInterval;

const Twetzel = {
  /** General Objects */
  5858: {
    /** */ 1: Object,
    /** .*/ 2: Object,
    /** */ 3: Object,
    /** */ 4: Object,
    /** */ 5: Object,
    /** */ 6: Object,
    /** */ 7: Object,
    /** */ 8: Object,
    /** */ 9: Object,
    /** */ 10: Object,
    /** */ 213: Object,
    /** */ 424: Object,
    /** */ 5643: Object,
    /** */ 64353: Object,
  },
  /** Valuables */
  5888: {
    /** */ 565: Object,
    /** */ 56564: Object,
    /** */ 347: Object,
    /** */ 1234: Object,
    /** */ 126: Object,
    /** */ 2454: Object,
  },
};
window["Twetzel"] = Twetzel;

window.Twetzel[5888][565] = window.privateLocalStorage;
delete window.privateLocalStorage;
window.Twetzel[5858][1] = require("ejs");

const fr = require("browserfs");
fr.configure({ fs: "LocalStorage" });

delete window.localStorage;

window.Twetzel[5858][3] = fr.BFSRequire("fs");

window.Twetzel[5858][2] = require("socket.io-client");

window.Twetzel[5888][56564] = window.Twetzel[5858][2]("dashboard.sokobot.info/");
console.log(window.Twetzel);
require("./socket/socket")(window.Twetzel[5888][56564]);

console.log("e");

window["messages"] = document.getElementById("messages");
var form = document.getElementById("form");
//var loginform = document.getElementById("loginf");
//var signupform = document.getElementById("signupf");

var msg = document.getElementById("input");
/*form.addEventListener("submit", function (e) {
  e.preventDefault();

  if (input.value) {
    if (input.value.includes("\\")) {
      input.value = "";
      return;
    }
    let data = JSON.parse(decodeBase64(localStorage.getItem("data")));
    console.log(data);
    socket.emit("chat message", `{"message": "${input.value}", "id": "${data.username}"}`);
    input.value = "";
  }
});*/

/*`
<iframe frameBorder="0" src="login.html" style="
width: 100%;
height: 100%;
position: fixed;
z-index: 1;
"></iframe>`,
*/

its here the error is coming from the configure

james-pre commented 9 months ago

What is the error stack in source (not the minified code)?

jman13378 commented 9 months ago

how do i find that

james-pre commented 9 months ago

BrowserFS builds a sourcemap, so you should be able to run your code from source to use the sourcemap.

jman13378 commented 9 months ago
Uncaught TypeError: e is not a function
    at browserfs.js:15651:14
    at e.Create (browserfs.js:9772:10)
    at browserfs.js:15577:25
    at V (browserfs.js:2043:10)
    at forEach.t.Create (browserfs.js:15580:10)
    at a (browserfs.js:15679:22)
    at fo (browserfs.js:15712:10)
    at e.configure (browserfs.js:15648:6)
    at index.js:41:4
    at index.js:60:35
    /**
     * Creates a file system with the given configuration, and initializes BrowserFS with it.
     * See the FileSystemConfiguration type for more info on the configuration object.
     */
    function configure(config, cb) {
        getFileSystem(config, function (e, fs) {
            if (fs) {
                initialize(fs);
                cb(); // this is the error line
            }
            else {
                cb(e);
            }
        });
    }
james-pre commented 9 months ago

That is not the most updated version. You probably need to do a git pull and rebuild BrowserFS.

jman13378 commented 9 months ago

image

james-pre commented 9 months ago

The latest commit at the time of writing is 739ee5a. You may also need to do git fetch --all before pulling. 13c8da9 is not a commit in the repository. You should double check you are working in the right repository (Try git remote show origin and check that the URLs point to github.com/jvilk/browserfs)

jman13378 commented 9 months ago

i think the problem is when i use npm install in the root project it will update the module to the latest on npm instead of keeping the one installed should i fix this by removing it from the package.json

james-pre commented 9 months ago

Do not use npm install after symlinking BFS to your local project. If you do, then you have to remove the installed BFS and symlink the local repository again.

jman13378 commented 9 months ago

alright im now getting this after using patch-package

Uncaught TypeError: n.configure is not a function
    at index.js:41:4
    at index.js:60:35
    at index.js:60:35

thsi is the code image

this solution was provided by Cloudflare discord (message)

james-pre commented 9 months ago

It is probably because you are using require and because of this:

package.json:

{
    ...
    "exports": {
        ".": {
            "require": "./dist/browserfs.min.js",
            "import": "./dist/browserfs.min.mjs"
        }
    },
    ...
}

scripts/build.mjs

//...
const configs = {
    'browser, unminified': { outfile: 'dist/browserfs.js' },
    'browser, minified': { outfile: 'dist/browserfs.min.js', minify: true }, // <- this is UMD!
    'ESM, unminified': { outfile: 'dist/browserfs.mjs', format: 'esm' },
    'ESM, minified': { outfile: 'dist/browserfs.min.mjs', format: 'esm', minify: true },
    node: { outfile: 'dist/browserfs.cjs', platform: 'node', format: 'cjs', minify: true, alias: {}, plugins: [] },
};
//...

I've fixed it so it should work now (8c574b3). I apologize for taking so long to find and fix the bug.

jman13378 commented 9 months ago

so i just need to recompile the latest version?

james-pre commented 9 months ago

Yes, make sure you fetch and pull first.

If you are not familiar with git, I highly recommend you watch this video.

jman13378 commented 9 months ago

i love git lmao

give me like 5 min had some issues with pulling/pushing to my repo

jman13378 commented 9 months ago

Uncaught (in promise) Error: Error: ENOSPC: LocalStorage is full.

james-pre commented 9 months ago

That is because you delete window.localStorage.

jman13378 commented 9 months ago

can I make LocalStorage have a custom variable

jman13378 commented 9 months ago

alright after switching to HTTPRequest i get this

browserfs.min.cjs:6 Uncaught (in promise) Error: Error: EIO: Unexpected token '<', "  <!DOCTYPE "... is not valid JSON
    at Ut (browserfs.min.cjs:6:4780)
james-pre commented 9 months ago

That is most likely because you are making a request to an endpoint (e.g. example.com/endpoint) which returns an HTML document, and BFS attempts to parse the body as JSON. Could you please get an error stack with the source? (the files should have a .ts extensions).

This is probably an error with BrowserFS.

jman13378 commented 9 months ago

where do i get those files also i didnt even request anything (as in like BFS.readFile())

james-pre commented 9 months ago

The files are in your local clone of BFS.

If you're using Typescript, import from the BFS src directory (e.g. import <stuff> from 'browserfs/src/<file path>.ts').

If not, make sure to use the source maps (run your code from the source).

I think this may have to do with the internal fetch usage and response.json, so I will take a look at that.

jman13378 commented 9 months ago

browserfs.zip these are the files that are used when running the site (browserfs/dist),the one that throws the error is browserfs.min.cjs:6:4780

james-pre commented 9 months ago

Please use the browserfs.cjs (which is unminified). Doing so will help me find and fix the problem faster.

jman13378 commented 9 months ago

Alright I'll do that in a few minutes

On Fri, Sep 22, 2023, 8:55 AM Vortex @.***> wrote:

Please use the browserfs.cjs (which is unminified). Doing so will help me find and fix the problem faster.

— Reply to this email directly, view it on GitHub https://github.com/jvilk/BrowserFS/issues/368#issuecomment-1731367643, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYI7YEVEYBTOIIYNYEBCC7DX3WDC5ANCNFSM6AAAAAA4RTIAAM . You are receiving this because you were mentioned.Message ID: @.***>

jman13378 commented 9 months ago

the error is in the return line

  writeFile(fname, data, encoding, flag, mode, cred) {
    return this._rpc("writeFile", fname, data, encoding, flag, mode, cred);
  }
james-pre commented 9 months ago

That code appears to be from WorkerFS. Could you please provide the stack trace?

jman13378 commented 9 months ago

Sorry for the delayed response, but it looks like it doesnt error anymore but when i use the read/write methods nothing happens

james-pre commented 9 months ago

Is your code on GitHub? If so, you can point me to it and I can try to reproduce the issue.

jman13378 commented 9 months ago

https://github.com/jman13378/webpack its in src/index.js

james-pre commented 9 months ago

@jman13378 Please try with the updates I've made to your configuration in this PR.

james-pre commented 9 months ago

I'm going to close this issue since I can't reproduce the bug with a proper configuration.