最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - I cannot understand " Module not found: Error: Can't resolve 'fs' '&qu

programmeradmin3浏览0评论

Having a little spare time I have tried reworking an old project of mine with new web techs that I like (Typescript, Pug and React). Everything worked fine until I tried adding pug.js into the mix with babel-plugin-transform-react-pug.

No matter how much I fiddle with the configurations I can't get the build phase to work and get the following errors:

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'  

The code is entirely in

Here is how to reproduce the errors:

  • Go to the root of the frontend folder,
  • Do an install (npm i)
  • Build with npx webpack

Could someone tell me what I'm doing wrong? Thank you in advance.

Having a little spare time I have tried reworking an old project of mine with new web techs that I like (Typescript, Pug and React). Everything worked fine until I tried adding pug.js into the mix with babel-plugin-transform-react-pug.

No matter how much I fiddle with the configurations I can't get the build phase to work and get the following errors:

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'  

The code is entirely in https://github./Hedgestock/Wikiwar

Here is how to reproduce the errors:

  • Go to the root of the frontend folder,
  • Do an install (npm i)
  • Build with npx webpack

Could someone tell me what I'm doing wrong? Thank you in advance.

Share Improve this question edited Jul 20, 2020 at 22:03 Melchia 24.4k23 gold badges108 silver badges129 bronze badges asked Oct 28, 2019 at 22:38 Aïto HedgestockAïto Hedgestock 411 gold badge1 silver badge2 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You could also run into this issue when your platform doesn't support file-system. SO try add this line to your webpack.config.js to add the corresponding pollyfills:

module.exports = {
  //...
  node: {
    fs: 'empty',
  }
};
发布评论

评论列表(0)

  1. 暂无评论