Multiple errors during upgrade to react-scripts 5.0.0
  • 27-Apr-2023
Lightrun Team
Author Lightrun Team
Multiple errors during upgrade to react-scripts 5.0.0

Multiple errors Module not found: Error: Can’t resolve path, buffer, stream during upgrade to react-scripts 5.0.0

Lightrun Team
Lightrun Team

Explanation of the problem

The user is attempting to upgrade to react-scripts 5.0.0 while using React 17.0.2, npm 7.14.0, and node 14.18.2. The user is also utilizing external dependencies such as shpjs, content-disposition, jszip, and safe-buffer. After attempting to start the project, the user encountered several errors related to modules not being found. These errors suggest that webpack < 5 included polyfills for node.js core modules by default, but this is no longer the case. To resolve the issue, the user should add a fallback for the missing modules and configure a polyfill for them, or use an empty module. The user was not encountering any errors when using react-scripts 4.0.3. To resolve the issue, the user installed each of the external dependencies and created a webpack.config.js file to include the fallback configuration. The user believes that the external dependencies should already be available in the project and is uncertain why they needed to be installed.


Troubleshooting with the Lightrun Developer Observability Platform


Getting a sense of what’s actually happening inside a live application is a frustrating experience, one that relies mostly on querying and observing whatever logs were written during development.
Lightrun is a Developer Observability Platform, allowing developers to add telemetry to live applications in real-time, on-demand, and right from the IDE.

  • Instantly add logs to, set metrics in, and take snapshots of live applications
  • Insights delivered straight to your IDE or CLI
  • Works where you do: dev, QA, staging, CI/CD, and production

Start for free today

Problem solution for Error: Can’t resolve path, buffer, stream during upgrade to react-scripts 5.0.0

One proposed solution is to identify which packages installed in the application are using Node.js core modules and replace them with dependency-free alternatives. One example of such a package is jsonwebtoken, a popular package used for JSON Web Tokens (JWT). This package has dependencies on Node.js core modules and can be replaced with jwt-decode, a dependency-free alternative that can be used solely for decoding JWTs. Another solution is to use react-app-rewired, a tool that allows you to extend the webpack.config without ejecting. This approach can help to address the issue by providing fallbacks for the missing modules in the browser environment.

To implement the first solution, you can use the npm or yarn package manager to search for packages that have dependencies on Node.js core modules. Once you have identified these packages, you can replace them with dependency-free alternatives or write your own code to handle the required functionality. For example, if you are using jsonwebtoken, you can install jwt-decode and use it instead.

Alternatively, you can use react-app-rewired to configure the webpack.config file for your application. This approach involves adding fallbacks for the missing modules in the browser environment by including require.resolve statements for the relevant packages in the webpack.config file. This solution can help to address the “Can’t resolve ‘crypto'” error by providing a workaround for the missing modules in the browser environment.

Other popular problems with Creating a react app

Problem: Limited Configuration Options

The first issue with create-react-app is its limited configuration options. While create-react-app provides a great starting point for building a React application, it can be challenging to customize it beyond its initial configuration. This limitation can cause issues for developers who need to add additional libraries or modify the default configuration.


One solution is to eject the app and modify the configuration files directly. However, this option should be used with caution as ejecting is a one-way operation, and it can be difficult to manage the configuration changes. Another option is to use a tool like react-app-rewired to modify the configuration without ejecting. React-app-rewired allows developers to modify the webpack configuration and babel configuration files, among others. By using this tool, developers can customize their create-react-app configuration while still maintaining the ability to update to new versions of create-react-app.

Problem: Large Bundle Size

The second issue with create-react-app is that it can generate a large bundle size. A large bundle size can slow down the application’s performance, especially for users on slower internet connections or mobile devices. This issue can be especially problematic for larger applications.


To reduce the bundle size, developers can use tools like code splitting and tree shaking. Code splitting involves breaking up the code into smaller chunks that can be loaded on-demand instead of all at once. Tree shaking is a technique that removes unused code from the final bundle. Additionally, developers can use libraries like Loadable Components to split the code more efficiently.

Problem: Lack of Server-Side Rendering

The third issue with create-react-app is the lack of built-in support for server-side rendering. Server-side rendering can improve the application’s performance, especially for users on slow connections or with slower devices. It can also help with SEO and provide a better user experience.


To add server-side rendering, developers can use tools like Next.js or Gatsby. Next.js is a framework that allows developers to build server-rendered React applications easily. Gatsby is a static site generator that allows developers to build static websites with React components. Both tools provide an easy way to add server-side rendering to a React application while maintaining compatibility with create-react-app.


A brief introduction of creating a react app

Create-react-app is a command-line interface tool that allows developers to quickly and easily create React applications without the need for configuration. It is a popular choice for developers who want to start building React applications quickly and efficiently. Create-react-app provides a pre-configured development environment with all the necessary tools and libraries to get started with React. It includes a development server, a hot-reloading feature, and many other features that make it easy to develop and test React applications.

Create-react-app uses webpack and babel under the hood to handle the bundling and transpiling of the application’s code. It also includes a pre-configured webpack configuration that is optimized for performance and code splitting. By default, create-react-app supports CSS modules and Sass, and it provides a simple way to add additional CSS preprocessors if needed. Create-react-app is maintained by Facebook and has a large community of contributors who regularly update and improve the tool. It is also compatible with many popular React libraries and tools, making it easy to integrate with other tools and services.

Most popular use cases for creating a react app

  1. Rapid Development: Create-react-app is designed to help developers quickly and efficiently create React applications without the need for manual configuration. By running a single command, developers can create a new React application with a pre-configured development environment that includes a server, hot-reloading, and many other features that make it easy to start building React applications. With Create-react-app, developers can focus on writing their code instead of spending time setting up the development environment.
  2. Customization: While Create-react-app provides a pre-configured development environment, it is also highly customizable. Developers can easily modify the configuration to suit their specific needs by using configuration files, such as .env, .babelrc, and webpack.config.js. This allows developers to add additional features, such as support for CSS preprocessors or custom webpack plugins, to their React applications.

Here is an example of how to add support for SASS in Create-react-app:

npm install node-sass

After installing the node-sass package, create a new .scss file in the src directory, and import it in your JavaScript file. Create-react-app will automatically handle the compilation and bundling of the SASS file.

  1. Integration with other tools and services: Create-react-app is compatible with many popular React libraries and tools, making it easy to integrate with other tools and services. For example, developers can easily add support for TypeScript by installing the @types/react package and updating their code to use TypeScript syntax. Create-react-app also works well with popular testing frameworks, such as Jest and Enzyme, making it easy to write and run tests for React applications.



It’s Really not that Complicated.

You can actually understand what’s going on inside your live applications.

Try Lightrun’s Playground

Lets Talk!

Looking for more information about Lightrun and debugging?
We’d love to hear from you!
Drop us a line and we’ll get back to you shortly.

By submitting this form, I agree to Lightrun’s Privacy Policy and Terms of Use.