SW Dev
SW Dev

Reputation: 103

RangeError: WebAssembly.Instance(): Out of memory: wasm memory

When compiling assets using Laravel Mix, I am getting the below error.

Steps I followed:

  1. Clone Laravel Git
  2. Install all node_modules using npm install
  3. Getting error when compiling assets using (npx mix or npm run dev/prod)

I have already tried reinstalling and different versions of node and npm but still getting the same error.

[webpack-cli] RangeError: WebAssembly.Instance(): Out of memory: wasm memory at create (/home/my_app/public_html/app/laravel/node_modules/webpack/lib/util/hash/wasm-hash.js:154:4) at module.exports (/home/my_app/public_html/app/laravel/node_modules/webpack/lib/util/createHash.js:152:27) at /home/my_app/public_html/app/laravel/node_modules/webpack/lib/DefinePlugin.js:289:22 at Hook.eval [as call] (eval at create (/home/my_app/public_html/app/laravel/node_modules/tapable/lib/HookCodeFactory.js:1:1), :194:1) at Hook.CALL_DELEGATE [as _call] (/home/my_app/public_html/app/laravel/node_modules/tapable/lib/Hook.js:14:14) at Compiler.newCompilation (/home/my_app/public_html/app/laravel/node_modules/webpack/lib/Compiler.js:1053:26) at /home/my_app/public_html/app/laravel/node_modules/webpack/lib/Compiler.js:1097:29 at Hook.eval [as callAsync] (eval at create (/home/my_app/public_html/app/laravel/node_modules/tapable/lib/HookCodeFactory.js:1:1), :22:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/my_app/public_html/app/laravel/node_modules/tapable/lib/Hook.js:18:14) at Compiler.compile (/home/my_app/public_html/app/laravel/node_modules/webpack/lib/Compiler.js:1092:28)

Specs: Laravel v8 with latest Laravel Mix version Node v16.13.0 NPM v8.1.0

I am using VPS with 8GB of memory.

Upvotes: 3

Views: 34066

Answers (3)

Lawrence E Bosumbe
Lawrence E Bosumbe

Reputation: 582

This WebAssembly.Instance(): Out of memory: wasm memory is Node specific error not Laravel.

Follow this process in order to solve this RangeError: WebAssembly.Instance(): Out of memory: wasm memory.

  1. I recommend to build your application locally then build and deploy it on live server.

  2. When building your Laravel application in order to be deployed, the build folder will be automatically created in public folder like so public/build.

  3. Zip your application and upload it to your live server.

  4. Extract your application in the live server.

  5. Move everything from your public folder to root where your package.json is located.

    Items to be moved to root folder include but not limited to:

    • build folder
    • .htaccess
    • index.php
    • robots.txt
    • favicon
  6. Inside of your index.php you change these settings below:

    Change this require DIR.'/../storage/framework/maintenance.php';

    To this require DIR.'/storage/framework/maintenance.php';

    Change this require DIR.'/../vendor/autoload.php';

    To this require DIR.'/vendor/autoload.php';

    Change this require DIR.'/../bootstrap/app.php';

    To this require DIR.'/bootstrap/app.php';

Then you're all set. Your application by any means should work.

This process is the simplest of them all and 99,99% guarantee.

If this is helpful, please don't hesitate to vote it up.

Upvotes: 2

Bruce Wen
Bruce Wen

Reputation: 11

I encountered this issue in Vim plugin coc.nvim and solved it by enlarge value of Virutal Memory by ulimit: https://medium.com/code-art/vim-the-whole-process-to-solve-coc-nvim-b6f3b3f68ebe

Not sure if your problem has the same root cause.

Upvotes: 0

SW Dev
SW Dev

Reputation: 103

An alternative answer has been posted at here. I used putty as a SSH client from my local machine to access my server and then I ran command (npx mix or npm run dev/prod) and it worked fine. This may not be the best solution but it somehow resolved my issue.

Upvotes: 7

Related Questions