有一点空闲时间,我尝试用我喜欢的新网络技术(Typescript、Pug 和 React)重新设计我的一个旧项目。一切工作正常,直到我尝试将 pug.js 添加到混合中babel-plugin-transform-react-pug
.
无论我如何摆弄配置,我都无法让构建阶段正常工作并出现以下错误:
ERROR in ./node_modules/uglify-js/tools/node.js
Module not found: Error: Can't resolve 'fs'
ERROR in ./node_modules/resolve/lib/sync.js
Module not found: Error: Can't resolve 'fs'
ERROR in ./node_modules/resolve/lib/async.js
Module not found: Error: Can't resolve 'fs'
ERROR in ./node_modules/pug-load/index.js
Module not found: Error: Can't resolve 'fs'
ERROR in ./node_modules/jstransformer/index.js
Module not found: Error: Can't resolve 'fs'
ERROR in ./node_modules/clean-css/lib/reader/load-original-sources.js
Module not found: Error: Can't resolve 'fs'
ERROR in ./node_modules/clean-css/lib/reader/apply-source-maps.js
Module not found: Error: Can't resolve 'fs'
ERROR in ./node_modules/clean-css/lib/reader/read-sources.js
Module not found: Error: Can't resolve 'fs'
代码完全在https://github.com/Hedgestock/Wikiwar https://github.com/Hedgestock/Wikiwar
以下是重现错误的方法:
- 转到根
frontend
folder,
- 进行安装(
npm i
)
- 构建与
npx webpack
有人可以告诉我我做错了什么吗?
先感谢您。
当您的平台不支持文件系统时,您也可能会遇到此问题。所以尝试将此行添加到您的webpack.config.js
添加相应的polyfill:
module.exports = {
//...
node: {
fs: 'empty',
}
};
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)