react 启动报错 ERROR in ./node_modules/fs-extra/lib/copy/copy-sync.js 5:13-28

项目运行好好的,然后就报一堆错误

起初我以为我安装了依赖倒置的问题,后来我只输出 hello world 都出错。折腾两晚上。。。还是度娘帮了我

复制代码
Compiled with problems:X

ERROR in ./node_modules/fs-extra/lib/copy/copy-sync.js 5:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\copy'

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 }


ERROR in ./node_modules/fs-extra/lib/copy/copy.js 5:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\copy'

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 }


ERROR in ./node_modules/fs-extra/lib/empty/index.js 7:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\empty'

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 }


ERROR in ./node_modules/fs-extra/lib/ensure/file.js 5:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\ensure'

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 }


ERROR in ./node_modules/fs-extra/lib/ensure/link.js 5:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\ensure'

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 }


ERROR in ./node_modules/fs-extra/lib/ensure/symlink-paths.js 3:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\ensure'

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 }


ERROR in ./node_modules/fs-extra/lib/ensure/symlink.js 5:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\ensure'

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 }


ERROR in ./node_modules/fs-extra/lib/mkdirs/utils.js 8:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\mkdirs'

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 }


ERROR in ./node_modules/fs-extra/lib/move/move-sync.js 5:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\move'

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 }


ERROR in ./node_modules/fs-extra/lib/move/move.js 5:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\move'

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 }


ERROR in ./node_modules/fs-extra/lib/output-file/index.js 7:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\output-file'

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 }


ERROR in ./node_modules/fs-extra/lib/remove/rimraf.js 5:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\remove'

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 }


ERROR in ./node_modules/fs-extra/lib/remove/rimraf.js 7:15-32

Module not found: Error: Can't resolve 'assert' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\remove'

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: { "assert": require.resolve("assert/") }'
    - install 'assert'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "assert": false }


ERROR in ./node_modules/fs-extra/lib/util/stat.js 5:13-28

Module not found: Error: Can't resolve 'path' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\util'

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 }


ERROR in ./node_modules/fs-extra/lib/util/stat.js 7:13-28

Module not found: Error: Can't resolve 'util' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\fs-extra\lib\util'

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: { "util": require.resolve("util/") }'
    - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "util": false }


ERROR in ./node_modules/graceful-fs/graceful-fs.js 1:9-22

Module not found: Error: Can't resolve 'fs' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\graceful-fs'


ERROR in ./node_modules/graceful-fs/graceful-fs.js 9:11-26

Module not found: Error: Can't resolve 'util' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\graceful-fs'

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: { "util": require.resolve("util/") }'
    - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "util": false }


ERROR in ./node_modules/graceful-fs/graceful-fs.js 86:6-29

Module not found: Error: Can't resolve 'assert' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\graceful-fs'

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: { "assert": require.resolve("assert/") }'
    - install 'assert'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "assert": false }


ERROR in ./node_modules/graceful-fs/legacy-streams.js 1:13-37

Module not found: Error: Can't resolve 'stream' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\graceful-fs'

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 }


ERROR in ./node_modules/graceful-fs/polyfills.js 1:16-36

Module not found: Error: Can't resolve 'constants' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\graceful-fs'

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: { "constants": require.resolve("constants-browserify") }'
    - install 'constants-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "constants": false }


ERROR in ./node_modules/jsonfile/index.js 6:8-21

Module not found: Error: Can't resolve 'fs' in 'D:\vueLearning\selfLearningProject\react-lesson\0706\node_modules\jsonfile'
复制代码

找到react 项目中的webpack.config.js

复制代码
// 290 行
resolve: {
// This allows you to set a fallback for where webpack should look for modules. // We placed these paths second because we want `node_modules` to "win" // if there are any conflicts. This matches Node resolution mechanism. // https://github.com/facebook/create-react-app/issues/253 fallback: { "path": false, "assert": false, "stream": false, "constants": false, "util": false, "fs": false, }, }
复制代码

完美解决,可以重启成功启动起来

这是因为有些包是Node.js的一部分,但它们在浏览器中不存在。

您需要指出它们或将它们设置为false。

更新您的网页包配置,将出现错误的软件包设置为false:os、dns、crypto、fs、net。或者更好的是,添加所有这些:

ps: https://www.5axxw.com/questions/content/ibfep2#question-recommend

posted @   zcm花开不败  阅读(2185)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示