spatie / server-side-rendering

Server side rendering JavaScript in a PHP application
https://sebastiandedeyne.com/posts/2018/server-side-rendering-javascript-from-php
MIT License
602 stars 34 forks source link

The command "node /var/www/tmp/c4e446ba25160cc5639395f94fb99626.js" failed. Exit Code: 1(General error) #64

Open dilipphycom opened 1 month ago

dilipphycom commented 1 month ago

I faced an issue after upgrading from Ubuntu 16 to 22 and upgrading the Node version from v14 to v20. The issue persists despite keeping other things the same on the old machine running Ubuntu 16. I had PHP 7.0 installed, and I also tried using PHP 7.2, but both versions gave the same error.

Also, the Vue files were generated and stored in the /var/www/tmp directory with permissions set to 744 for www-data:www-data.

The configuration of my old system was as follows: OS: Ubuntu 16 PHP: 7.0 Node: 14

The current system configuration is: OS: Ubuntu 16 PHP: 7.0 (tried with PHP 7.2, got the same problem) Node: 20 (tried with 14 as well, got the same problem)

I have tried upgrading the package spatie/server-side-rendering 0f 0.2.6 to 0.3.2. But still got the same error.

My Error is:

The command "node /var/www/tmp/c4e446ba25160cc5639395f94fb99626.js" failed. Exit Code: 1(General error) Working directory: /var/www/v3 Output: ================ "

** Here load My HTML part without CSS *** ** After that given JS error**

" Error Output: ================ /var/www/tmp/c4e446ba25160cc5639395f94fb99626.js:3 };var process = process || { env: {} };process.env.NODE_ENV = "production";process.env.VUE_ENV = "server";var context = {"showAllRequisitions":true,"createRequisition":true,"url":"\/requisitions","navOptions":[{"text":"Home","url":"\/dashboard","icon":"mdi-view-dashboard-outline"}, ...................

My goal is to upgrade the OS and keep the existing system running as it is. Without changing the code, I will upgrade the package version as per the dependencies if required.

dilipphycom commented 1 month ago

Hey everyone,

I found the issue in my setup or code: it was a Node version problem.

My mistake was that I initially set up the server with Node 20. Then, when I downgraded the Node version to 14, it appeared to downgrade successfully. However, when I checked using the "node -v" command, it was still showing Node "14.21.0". But during code runtime, it was still using Node 20, likely because somewhere in the Node configuration path, the default Node version was set to 20. So essentially, in my code, there was a Vue node package dependency issue due to Node 20.

I suggest providing a more detailed error message about the return from the node package, rather than a general one.