[Vuejs]-Vue 3 build + webpack causes JavaScript heap out of memory

0👍

Either you have too many files or you have few files that are too large. The only thing you can do is try increasing the memory quota using the node flag --max-old-space-size.

Before running the Webpack, set the memory options using environment variables:

// 8GB of memory
NODE_OPTIONS=--max_old_space_size=8192

And, then run your Webpack command. Alternately, you can also use:

node --max-old-space-size=8192 ./node_modules/webpack/bin/webpack.js

0👍

The problem turned out to be my tsconfig.json. There is also an exclude rule in that file. Next time I opened VS Code, it reminded me to check that file for excludes. It knew! Once I added the large directory to the tsconfig exclude rule, the problem went away.

So I guess this doesn’t have to do with vue or vue-loader or even webpack specifically (unless one of those also uses the tsconfig). But I didn’t think of this, because mine is a pure .js app and prior to vue, there was no need for tsconfig.

I also realize I didn’t include that config in my question:

{
  "compilerOptions": {
    "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
    "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
    "allowJs": true /* Allow javascript files to be compiled. */,
    "sourceMap": true,
    "outDir": "./build",
    "baseUrl": ".",
    "declaration": false,
    "strict": true /* Enable all strict type-checking options. */,
    "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
    "skipLibCheck": true /* Skip type checking of declaration files. */,
    "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
    "moduleResolution": "node",
    "lib": ["dom", "es2017"],
    "removeComments": false
  },
  "exclude": ["node_modules", "ise", "bin", "obj", "kite"]
}

Leave a comment