Reputation: 103
When compiling assets using Laravel Mix, I am getting the below error.
Steps I followed:
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
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.
I recommend to build your application locally then build and deploy it on live server.
When building your Laravel application in order to be deployed, the build folder will be automatically created in public folder like so public/build.
Zip your application and upload it to your live server.
Extract your application in the live server.
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:
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
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