gpt4 book ai didi

javascript - 获取未找到原始 fs 模块的警告

转载 作者:行者123 更新时间:2023-12-04 17:39:10 25 4
gpt4 key购买 nike

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

当我执行 yarn build 时,我收到如下警告 -

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

我的 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 如下所示 -

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'
}
]
}
}

我尝试了不同的方法但都失败了 -

  • 在依赖中添加了 original-fs
  • 在 webpack.config.js 中添加了 node: { fs: 'empty' }
  • target: 'node' 替换为 target: 'async-node'

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

最佳答案

我可以通过将其添加到我的 package.json 来修复它:

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

关于javascript - 获取未找到原始 fs 模块的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55335559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com