Javascript 未找到原始fs模块的警告

Javascript 未找到原始fs模块的警告,javascript,node.js,webpack,package.json,Javascript,Node.js,Webpack,Package.json,我尝试了Github问题中提到的各种方法,但我无法解决下面的警告- 当我进行纱线构建时,我得到如下警告- 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_mod

我尝试了Github问题中提到的各种方法,但我无法解决下面的警告-

当我进行
纱线构建时
,我得到如下警告-

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
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'
      }
    ]
  }
}
我的
package.json
如下所示

{
  "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"
  }
}
webpacl.config.js
如下所示-

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
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'
      }
    ]
  }
}
我尝试了不同的方法,但失败了-

  • 在依赖项中添加了原始fs
  • 在webpack.config.js中添加了
    节点:{fs:'empty'}
  • target:'node'
    替换为
    target:'async node'

还有其他解决方法吗?还是我遗漏了什么?

我可以通过将此添加到我的包中来修复它。json:

"browser": {
    "original-fs": false
}

谢谢@Nikolas这是一个很长的老问题,我甚至不记得我在哪里面对这个问题以及我是如何解决的。无论如何,让我们看看是否有其他人能发现这一点有用。我将标记正确(如果有人投票,请点击我或在评论中提及我)