React 版本是18 :
Compiled with problems:
×
ERROR in ./node_modules/markdown-it-copy/index.js 1:11-24
Module not found: Error: Can't resolve 'fs' in 'C:\Users\hzheng057\Desktop\Code\GosuModel\frontend\node_modules\markdown-it-copy'
ERROR in ./node_modules/markdown-it-copy/index.js 2:13-28
Module not found: Error: Can't resolve 'path' in 'C:\Users\hzheng057\Desktop\Code\GosuModel\frontend\node_modules\markdown-it-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 }
根据报错信息内容,因为markdown-it-copy插件试图在浏览器环境中使用fs和path模块,这两个模块是Node.js的核心模块,通常不可在浏览器环境中使用。Webpack 5不再默认包含Node.js核心模块的polyfill。如果你的项目依赖于这些模块,需要手动添加polyfill。
希望作者解决,另外希望能够提供options配置项让用户可以用自己的自定义的copy函数方法
React 版本是18 :
Compiled with problems:
×
ERROR in ./node_modules/markdown-it-copy/index.js 1:11-24
Module not found: Error: Can't resolve 'fs' in 'C:\Users\hzheng057\Desktop\Code\GosuModel\frontend\node_modules\markdown-it-copy'
ERROR in ./node_modules/markdown-it-copy/index.js 2:13-28
Module not found: Error: Can't resolve 'path' in 'C:\Users\hzheng057\Desktop\Code\GosuModel\frontend\node_modules\markdown-it-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 }