GithubHelp home page GithubHelp logo

Comments (5)

rektdeckard avatar rektdeckard commented on July 16, 2024

This is a pretty classic out-of-memory error that unfortunately happens because your build process is probably trying to load thousands of icons into memory while bundling, which is usually not necessary.

You can fix this a few ways:

  1. Use full import paths for each icon, so that the bundler only loads what you use:
// this
import { Check } from "@phosphor-icons/react/dist/csr/Check";
import { Smiley } from "@phosphor-icons/react/dist/csr/Smiley";
// instead of this
import { Check, Smiley } from "@phosphor-icons/react";
  1. Increase the memory limit of the Node process. By default, I believe, Node only allocates 1024MB per process, and this error occurs when it tries to allocate something new and doesn't find enough memory remaining. You can give it more memory by changing the max-old-space-size option by setting an environment variable before calling your command:
export NODE_OPTIONS="--max-old-space-size=4096"
npm run build

You can also just add it to the script in package.json:

{
  "scripts": {
    "build": "NODE_OPTIONS='--max-old-space-size=4096' vite build"
  }
}

Obviously the rest of your build command will differ based on the tools you're using, but it should work with everything. You can play around with the number, but 4GB should be plenty.

from react.

ChiragDugar02 avatar ChiragDugar02 commented on July 16, 2024

Hi @rektdeckard ,

We changed the imports according to your suggestion and we also tried running the server by increasing the node memory allocated. It still doesn't work. However, this time it throws some other error.

Screenshot 2024-06-12 at 12 52 06 PM

from react.

rektdeckard avatar rektdeckard commented on July 16, 2024

That error is entirely different, and looks to be webpack exceeding the maximum string length in Node, which depending on your version of Node could be as low as ~260MB. I am not here to debug your application, but it sounds like you have some problems in your build setup.

Try upgrading Node (and webpack) if you're on an old version, look for anything that is concatenating into a massive string, and maybe try doing some debugging yourself.

from react.

rektdeckard avatar rektdeckard commented on July 16, 2024

BTW it looks like you are using Node 15, which reached End Of Life like 2 years ago. Upgrading may resolve the problem, as memory allocation has undoubtedly improved in 9 major versions of Node.

from react.

rektdeckard avatar rektdeckard commented on July 16, 2024

Closing as out-of-scope. This is simply too old a runtime for us to support.

from react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.