file-system-cache icon indicating copy to clipboard operation
file-system-cache copied to clipboard

3.0.0-alpha8 Error: Dynamic require of "fs" is not supported

Open binarymax opened this issue 10 months ago • 1 comments

For some reason, when using 3.0.0-alpha8 like this:

import Cache from 'file-system-cache';

I receive the following error:

Error: Dynamic require of "fs" is not supported
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:6:382
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:6:7064
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:6:458
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:7:4622
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:6:458
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:7:9971
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:6:458
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:11:2149
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:6:458
    at file:///Users/max/myproject/node_modules/file-system-cache/lib/index.js:12:3721

The issue goes away when I downgrade back to 2.4.7.

Here is my package.json:

{
  "name": "myproject",
  "private": true,
  "version": "1.0.0",
  "type": "module",
  "workspaces": [
    "website"
  ],
  "dependencies": {
    "commander": "^13.1.0",
    "ejs": "^3.1.10",
    "es-main": "^1.3.0",
    "express": "^4.18.2",
    "file-system-cache": "^3.0.0-alpha.8",
    "he": "^1.2.0",
    "http-errors": "^2.0.0",
    "morgan": "^1.10.0",
    "serialize-javascript": "^6.0.2",
    "sqlite3": "^5.1.7",
    "string-strip-html": "^13.4.8",
    "ws": "^8.18.0"
  },
  "devDependencies": {
    "nodemon": "^3.1.9"
  },
  "scripts": {
    "dev:website": "npm run dev --workspace=website"
  }
}

Not sure if you will be able to reproduce, but downgrading fixed it for me.

binarymax avatar Feb 20 '25 20:02 binarymax

Almost forgot: Node v22.13.1

binarymax avatar Feb 20 '25 21:02 binarymax

Same here

mrfullset avatar Mar 26 '25 17:03 mrfullset

Same issue on deno 2.3.3 as well. Falling back to 2.4.7 does fix the issue.

larrybahr-ocelot avatar May 20 '25 23:05 larrybahr-ocelot