4

I am getting this error while starting my node js app in my cpanel.

RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
at internal/deps/cjs-module-lexer/dist/lexer.js:1:33573

but while i am developing in localhost, everything works just fine.

Here is my output log,

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/opt/alt/alt-nodejs14/root/usr/bin/node',
1 verbose cli   '/opt/alt/alt-nodejs14/root/usr/bin/npm',
1 verbose cli   'run-script',
1 verbose cli   'start',
1 verbose cli   '--'
1 verbose cli ]
2 info using npm@6.14.13
3 info using node@v14.17.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle thewebapp@1.0.0~prestart: thewebapp@1.0.0
6 info lifecycle thewebapp@1.0.0~start: thewebapp@1.0.0
7 verbose lifecycle thewebapp@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle thewebapp@1.0.0~start: PATH: /opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/node-gyp-bin:/home/proudpos/backend/node_modules/.bin:/opt/alt/alt-nodejs14/root/usr/bin:/home/proudpos/nodevenv/backend/14/bin:/opt/alt/alt-nodejs14/root/usr/bin:/home/proudpos/nodevenv/backend/14/lib/bin/:/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin
9 verbose lifecycle thewebapp@1.0.0~start: CWD: /home/proudpos/backend
10 silly lifecycle thewebapp@1.0.0~start: Args: [ '-c', 'node server.js' ]
11 silly lifecycle thewebapp@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle thewebapp@1.0.0~start: Failed to exec start script
13 verbose stack Error: thewebapp@1.0.0 start: `node server.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:375:28)
13 verbose stack     at ChildProcess.<anonymous> (/opt/alt/alt-nodejs14/root/usr/lib/node_modules/npm/node_modules.bundled/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:375:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid thewebapp@1.0.0
15 verbose cwd /home/proudpos/backend
16 verbose Linux 3.10.0-962.3.2.lve1.5.60.el7.x86_64
17 verbose argv "/opt/alt/alt-nodejs14/root/usr/bin/node" "/opt/alt/alt-nodejs14/root/usr/bin/npm" "run-script" "start" "--"
18 verbose node v14.17.3
19 verbose npm  v6.14.13
20 error code ELIFECYCLE
21 error errno 1
22 error thewebapp@1.0.0 start: `node server.js`
22 error Exit status 1
23 error Failed at the thewebapp@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I searched but could not found any answer. need some help with this.

Aman Chaudhary
  • 802
  • 3
  • 10
  • 27

5 Answers5

8

I had the same issue, I was running node command in background in a vps, the all over sudden it went down, I went to my cpanel terminal and stopped the job the tried restarting but it gave me that error, I couldn't fix it. I opened my local machine's terminal, accessed the app via ssh, and reuploaded the code then it worked fine. I still do not understand the difference between cpanel terminal and my laptops terminal.

  • 1
    today i installed a new lts version of node using nvm and i got the same problem, but just with the new version (16.13.0) via the cpanel terminal, using a cmder works fine – juanbits Nov 17 '21 at 18:57
  • Could you pls explain more how u fixed it – Constant Dec 31 '21 at 14:26
  • I bet you are running it on Cpanel's commandline tool. I simply ran it on my local machines' terminal via ssh and it worked, it still didn't work on Cpanel's terminal – Dennis Kiprotich Jan 03 '22 at 21:18
1

Just ssh and run npm run dev and it will work.In my case I did not reupload the code.

wanjiku
  • 251
  • 6
  • 14
0

I had the same error, and surprisingly i ran the same command npm run dev but from SSH not cPanel, and it is working fine !

Adham shafik
  • 1,044
  • 1
  • 13
  • 16
0

Well, It turned out I was using type: "module" in my package.json file.

this was the issue that kept blocking cpanel to run my application. It was working fine for me on ssh but not normally via cpanel. my node -v returned v14.18.1

  • I changed my code from import to require syntax.
  • removed type: "module" from package.json
  • refactored my code accordingly
  • and it worked normally on cpanel.
Dharman
  • 30,962
  • 25
  • 85
  • 135
M. Junaid Salaat
  • 3,765
  • 1
  • 23
  • 25
0

The important point is that you are using your hosting provider cPanel (shared hosting) or another VPS with a control panel with a built-in SSH terminal.

So when you run an SSH terminal that your hosting provider offers you. Then, thanks to the power of your server, it emulates an SSH connection and thereby limits its ability to execute commands.

When I encountered such an error, I studied the errors in the logs and saw there that I did not have memory leaks, but at the same time I had enough server power, namely memory. And then I came to the conclusion to connect via SSH via Putty (or you can use your windows SSH terminal or a regular terminal on MacOS). Thus, do not waste your server's memory resource on emulating an SSH terminal.

I solved this problem like this!

First run your Node.js in Development mode (I had version 14.20.1) in cPanel you will be prompted to activate it.

After you connect to the server directly from the SSH terminal (Shell or MacOS, Linux), execute the NODE.JS activation command that cPanel gave you

It is important to run this command in a terminal so that you can run "NPM" commands

source /home/{user}/nodevenv/{project_name}/14/bin/activate && cd /home/{user}/nodevenv/{project_name}

Then

npm install

npm run dev

and ready to check your site;

To get the result on a permanent basis, you need to build

to do this, put your NODE.JS in production mode and run the following commands in the terminal

source /home/{user}/nodevenv/{project_name}/14/bin/activate && cd /home/{user}/nodevenv/{project_name}

npm install

npm run build