Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Can't resolve 'fs' when using @next/bundle-analyzer #1811

Open
mg-aceik opened this issue Jun 6, 2024 · 1 comment
Open
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug

Comments

@mg-aceik
Copy link

mg-aceik commented Jun 6, 2024

Describe the Bug

When the @next/bundle-analyzer is installed and configured, building the site gives:

  ../../node_modules/webpack-bundle-analyzer/lib/analyzer.js
  Module not found: Can't resolve 'fs'
  
  https://nextjs.org/docs/messages/module-not-found
  
  Import trace for requested module:
  ../../node_modules/webpack-bundle-analyzer/lib/viewer.js
  ../../node_modules/webpack-bundle-analyzer/lib/index.js
  ../../node_modules/@next/bundle-analyzer/index.js
  ./next.config.js
  ./src/core/FEAASScripts/FEAASScripts.tsx
  ./src/Scripts.tsx
  ./src/Layout.tsx
  ./src/pages/500.tsx

To Reproduce

  1. npx create-sitecore-jss nextjs,nextjs-sxa,nextjs-multisite,nextjs-xmcloud
  2. Follow https://nextjs.org/docs/app/building-your-application/optimizing/bundle-analyzer and enable the analyzer
  3. npm run build

Expected Behavior

Site should build successfully.

Possible Fix

The issue is due to

- import nextConfig from 'next.config';

If this import and its usages are commented out, then the error goes away, however of course this will possibly break the FEAAS functionality.

Provide environment information

  • Sitecore Version: XM Cloud
  • JSS Version: 22.0.0
  • Browser Name and version: Chrome latest
  • Operating System and version (desktop or mobile): Windows 11
  • Link to your project (if available): n/a
@illiakovalenko
Copy link
Contributor

@mg-aceik Thank you for submitting this ticket! I've added a ticket containing all the details to our internal backlog for thorough review

@illiakovalenko illiakovalenko added the backlog Issue/PR/discussion is reviewed and added to backlog for the further work label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issue/PR/discussion is reviewed and added to backlog for the further work 🐞 bug
Projects
None yet
Development

No branches or pull requests

2 participants