首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >webpack <5用于默认情况下包括node.js核心模块的多填充。现在情况不再是这样了

webpack <5用于默认情况下包括node.js核心模块的多填充。现在情况不再是这样了
EN

Stack Overflow用户
提问于 2022-03-01 23:13:23
回答 2查看 2K关注 0票数 1

我得到了错误:

22错误包含未显示的详细信息。编译失败。webpack <5用于默认情况下包括node.js核心模块的多填充。现在已经不是这样了。验证是否需要此模块,并为其配置一个多填充。

未找到模块:错误:无法解决‘C:\Users\joshm\下载\新文件夹(14)\myapp\节点_模块\body-解析器\lib’中的“zlib”更改:默认情况下,webpack <5用于包含node.js核心模块的多填充。现在已经不是这样了。验证是否需要此模块,并为其配置一个多填充。

代码语言:javascript
复制
If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
        - install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "zlib": false }
asset static/js/bundle.js 2.84 MiB [emitted] (name: main) 1 related asset
asset index.html 1.67 KiB [emitted]
asset asset-manifest.json 190 bytes [emitted]
cached modules 2.42 MiB (javascript) 28.3 KiB (runtime) [cached] 271 modules

WARNING in ./node_modules/express/lib/view.js 74:13-25
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/express/lib/application.js 26:11-28
 @ ./node_modules/express/lib/express.js 19:12-36
 @ ./node_modules/express/index.js 10:0-41
 @ ./src/Login.js 6:0-35 29:23-36
 @ ./src/App.js 8:0-28 39:38-43
 @ ./src/index.js 7:0-24 10:33-36

1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

ERROR in ./node_modules/body-parser/lib/read.js 20:11-26
Module not found: Error: Can't resolve 'zlib' in 'C:\Users\joshm\Downloads\New folder (14)\myapp\node_modules\body-parser\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
        - install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "zlib": false }
 @ ./node_modules/body-parser/lib/types/json.js 21:11-29
 @ ./node_modules/body-parser/index.js 134:15-42
 @ ./node_modules/express/lib/express.js 13:17-39
 @ ./node_modules/express/index.js 10:0-41
 @ ./src/Login.js 6:0-35 29:23-36
 @ ./src/App.js 8:0-28 39:38-43
 @ ./src/index.js 7:0-24 10:33-36

ERROR in ./node_modules/content-disposition/index.js 19:15-39
Module not found: Error: Can't resolve 'path' in 'C:\Users\joshm\Downloads\New folder (14)\myapp\node_modules\content-disposition'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }
 @ ./node_modules/express/lib/response.js 15:25-55
 @ ./node_modules/express/lib/express.js 27:10-31
 @ ./node_modules/express/index.js 10:0-41
 @ ./src/Login.js 6:0-35 29:23-36
 @ ./src/App.js 8:0-28 39:38-43
 @ ./src/index.js 7:0-24 10:33-36

ERROR in ./node_modules/cookie-signature/index.js 4:13-30
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\joshm\Downloads\New folder (14)\myapp\node_modules\cookie-signature'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
        - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "crypto": false }
 @ ./node_modules/express/lib/response.js 35:11-43
 @ ./node_modules/express/lib/express.js 27:10-31
 @ ./node_modules/express/index.js 10:0-41
 @ ./src/Login.js 6:0-35 29:23-36
 @ ./src/App.js 8:0-28 39:38-43
 @ ./src/index.js 7:0-24 10:33-36

ERROR in ./node_modules/destroy/index.js 12:17-41
Module not found: Error: Can't resolve 'fs' in 'C:\Users\joshm\Downloads\New folder (14)\myapp\node_modules\destroy'
 @ ./node_modules/send/index.js 19:14-32
 @ ./node_modules/express/lib/response.js 45:11-26
 @ ./node_modules/express/lib/express.js 27:10-31
 @ ./node_modules/express/index.js 10:0-41
 @ ./src/Login.js 6:0-35 29:23-36
 @ ./src/App.js 8:0-28 39:38-43
 @ ./src/index.js 7:0-24 10:33-36

ERROR in ./node_modules/destroy/index.js 14:13-30
Module not found: Error: Can't resolve 'stream' in 'C:\Users\joshm\Downloads\New folder (14)\myapp\node_modules\destroy'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }
 @ ./node_modules/send/index.js 19:14-32
 @ ./node_modules/express/lib/response.js 45:11-26
 @ ./node_modules/express/lib/express.js 27:10-31
 @ ./node_modules/express/index.js 10:0-41
 @ ./src/Login.js 6:0-35 29:23-36
 @ ./src/App.js 8:0-28 39:38-43
 @ ./src/index.js 7:0-24 10:33-36

ERROR in ./node_modules/etag/index.js 18:13-30
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\joshm\Downloads\New folder (14)\myapp\node_modules\etag'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
        - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "crypto": false }
 @ ./node_modules/express/lib/utils.js 25:11-26
 @ ./node_modules/express/lib/application.js 30:18-48 32:25-62 34:19-50
 @ ./node_modules/express/lib/express.js 19:12-36
 @ ./node_modules/express/index.js 10:0-41
 @ ./src/Login.js 6:0-35 29:23-36
 @ ./src/App.js 8:0-28 39:38-43
 @ ./src/index.js 7:0-24 10:33-36

ERROR in ./node_modules/etag/index.js 20:12-31
Module not found: Error: Can't resolve 'fs' in 'C:\Users\joshm\Downloads\New folder (14)\myapp\node_modules\etag'
 @ ./node_modules/express/lib/utils.js 25:11-26
 @ ./node_modules/express/lib/application.js 30:18-48 32:25-62 34:19-50
 @ ./node_modules/express/lib/express.js 19:12-36
 @ ./node_modules/express/index.js 10:0-41
 @ ./src/Login.js 6:0-35 29:23-36
 @ ./src/App.js 8:0-28 39:38-43
 @ ./src/index.js 7:0-24 10:33-36

ERROR in ./node_modules/express/lib/application.js 28:11-26
Module not found: Error: Can't resolve 'http' in 'C:\Users\joshm\Downloads\New folder (14)\myapp\node_modules\express\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }
 @ ./node_modules/express/lib/express.js 19:12-36
 @ ./node_modules/express/index.js 10:0-41
 @ ./src/Login.js 6:0-35 29:23-36
 @ ./src/App.js 8:0-28 39:38-43
 @ ./src/index.js 7:0-24 10:33-36



22 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.69.1 compiled with 22 errors and 1 warning in 2554 ms

webpack.config.js
module.exports = {
    
    resolve: {
        fallback: {
            "fs": false
        },
    }
}
EN

回答 2

Stack Overflow用户

发布于 2022-03-03 09:51:03

我也有同样的问题。这个解决方案将帮助你:

node-polyfill-webpack-plugin

  • Write
  1. npm i将此代码转化为vue.config.js

代码语言:javascript
复制
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

module.exports = {
  configureWebpack: {
    plugins: [new NodePolyfillPlugin()]
  }
};

票数 2
EN

Stack Overflow用户

发布于 2022-03-30 17:44:29

当您将未识别的模块导入应用程序时,就会发生这种情况。检查从高速公路导入的所有模块。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71315671

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档