Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting warning for original-fs module not found

I tried various ways mentioned in Github's issues, but I am unable to resolve the warning below -

When I do yarn build, I get warning as below -

WARNING in ./node_modules/adm-zip/util/fileSystem.js
Module not found: Error: Can't resolve 'original-fs' in './node_modules/adm-zip/util'
 @ ./node_modules/adm-zip/util/fileSystem.js
 @ ./node_modules/adm-zip/util/utils.js
 @ ./node_modules/adm-zip/util/index.js
 @ ./node_modules/adm-zip/adm-zip.js

My package.json looks like this

{
  "name": "MyApp",
  "version": "0.2.1",
  "description": "My Command Line Interface",
  "repository": "https://mylink.com/MyApp",
  "main": "myApp.js",
  "bin": {
    "myApp": "./dist/myApp.js"
  },
  "files": [
    "dist/"
  ],
  "author": "MySelf",
  "license": "UNLICENSED",
  "private": false,
  "scripts": {
    "build": "webpack --config webpack.config.js",
    "commit": "yarn git-cz",
    "commitmsg": "commitlint -e $GIT_PARAMS",
    "lint": "eslint --ext .js src",
    "lint:watch": "yarn esw -w src",
    "release": "standard-version -n",
    "start": "yarn build --watch & yarn test --notify --silent --watch & yarn lint:watch",
    "test": "jest",
    "unit:ci": "jest"
  },
  "dependencies": {
    "@angular/cli": "^7.3.4",
    "@vue/cli": "3.4.1",
    "adm-zip": "^0.4.13",
    "chalk": "2.4.2",
    "cheerio": "^1.0.0-rc.2",
    "commander": "2.19.0",
    "cross-spawn": "^6.0.5",
    "dotenv-webpack": "^1.7.0",
    "find-up": "3.0.0",
    "glob": "^7.1.3",
    "inquirer": "6.2.1",
    "inquirer-autocomplete-prompt": "1.0.1",
    "inquirer-fuzzy-path": "1.0.0",
    "log-symbols": "2.2.0",
    "ora": "3.0.0",
    "request": "^2.88.0",
    "simple-git": "^1.96.0",
    "yo": "^2.0.5"
  },
  "devDependencies": {
    "@commitlint/cli": "7.3.2",
    "@commitlint/config-conventional": "7.3.1",
    "babel-core": "^6.26.3",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^23.6.0",
    "babel-preset-env": "^1.7.0",
    "command-exists": "^1.2.7",
    "commitizen": "3.0.5",
    "cz-conventional-changelog": "2.1.0",
    "debug": "^4.1.1",
    "dotenv": "^6.2.0",
    "eslint": "^5.4.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jest": "^22.1.3",
    "eslint-plugin-node": "^8.0.1",
    "eslint-plugin-promise": "^4.0.0",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-watch": "^4.0.2",
    "imports-loader": "0.8.0",
    "jest": "^23.6.0",
    "regenerator-runtime": "^0.13.1",
    "webpack": "4.29.6",
    "webpack-build-notifier": "0.1.31",
    "webpack-cli": "3.3.0",
    "yorkie": "^2.0.0",
    "lodash": "^4.17.11"
  },
  "engines": {
    "node": ">= 10.12.0",
    "npm": ">= 3.0.0",
    "yarn": ">= 1.7.0"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  },
  "gitHooks": {
    "commit-msg": "commitlint -e $GIT_PARAMS",
    "pre-commit": "yarn run lint",
    "pre-push": "yarn run lint && yarn run test"
  }
}

And webpacl.config.js looks like as below -

const path = require('path')
const webpack = require('webpack')
const WebpackBuildNotifierPlugin = require('webpack-build-notifier')
const Dotenv = require('dotenv-webpack');

function srcPath (subdir) {
  return path.join(__dirname, 'src', subdir)
}

module.exports = {
  mode: 'production',
  target: 'node',
  entry: './src/myApp.js',
  output: {
    filename: 'myApp.js'
  },
  plugins: [
    new Dotenv(),
    new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true }),
    new WebpackBuildNotifierPlugin({
      title: 'MyApp CLI Build',
      logo: path.resolve('./myApp-logo.png'),
      sound: false
    })
  ],
  module: {
    rules: [
      // corrects "can't resolve './rx.lite'" issue from inquirer-fuzzy-path, see:
      // https://github.com/Reactive-Extensions/RxJS/issues/1117#issuecomment-308210947
      {
        test: /rx\.lite\.aggregates\.js/,
        use: 'imports-loader?define=>false'
      }
    ]
  }
}

I tried following different ways but failed -

  • Added original-fs in dependency
  • Added node: { fs: 'empty' } in webpack.config.js
  • Replaced target: 'node' with target: 'async-node'

Are there any other ways to resolve it? Or Am I missing anything?

like image 765
Jimit Patel Avatar asked Feb 28 '26 07:02

Jimit Patel


1 Answers

I could fix it by adding this to my package.json:

"browser": {
    "original-fs": false
}
like image 69
Nikolas Avatar answered Mar 01 '26 19:03

Nikolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!