我有一点空闲时间,尝试用我喜欢的新网络技术(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中。
以下是如何重现错误的方法:
- 进入
frontend
文件夹的根目录, - 执行安装操作(
npm i
), - 使用
npx webpack
进行构建。
请问有人能告诉我我做错了什么吗? 提前感谢。