• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue Multiple nodejs versions

sanek_190

New Pleskian
Server operating system version
CentOS 7
Plesk version and microupdate number
18.0.51
I have multiple versions of nodejs on plesk server. When I try to run the npm command through the panel, I get the error /usr/bin/env: node: No such file or directory. Can I access npm via the full path in the panel? or via ssh? /opt/plesk/node/16/bin/npm ...

How can I solve this without making symlinks in /usr/bin since I have multiple versions of nodejs.
 

Attachments

  • node.png
    node.png
    38.1 KB · Views: 21
Calling of node related utilities should work over nodenv.
To ensure that node-related utilities are functioning properly, please check if you have the following files and directories in the home directory of your domain:
  1. /var/www/vhost/[youdomain]/.nodenv directory: This directory is essential for nodenv to manage different versions of Node.js.
  2. /var/www/vhost/[yourdomain]/.node-version file: This file specifies the Node.js version that should be used for your domain.
If either of these components is missing, it might cause issues with calling node-related utilities. Ensure that both the .nodenv directory and the .node-version file are present in the correct location.
You could use following commands to init nodenv if the directory or/and file are missing:
> mkdir ~/.nodenv
> ln -s "/opt/plesk/node" ~/.nodenv/versions
> eval "$(nodenv init -)"
> echo [your_node_version] >> ~/.node-version
 
Calling of node related utilities should work over nodenv.
To ensure that node-related utilities are functioning properly, please check if you have the following files and directories in the home directory of your domain:
  1. /var/www/vhost/[youdomain]/.nodenv directory: This directory is essential for nodenv to manage different versions of Node.js.
  2. /var/www/vhost/[yourdomain]/.node-version file: This file specifies the Node.js version that should be used for your domain.
If either of these components is missing, it might cause issues with calling node-related utilities. Ensure that both the .nodenv directory and the .node-version file are present in the correct location.
You could use following commands to init nodenv if the directory or/and file are missing:
During the restore, something happened to the /var/www/vhost/mydomain/.nodenv directory, it became empty. Now I see an error during the backup process

Not all the data from /var/www/vhosts/mydomain was backed up successfully:
.nodenv/versions: Cannot open: Permission denied

Permissions on the .nodenv directory
drwxr-xr-x 4 temp_user psacln 35 May 13 09:56 .nodenv

plesk repair fs shows no problems with this directory. How can I restore my rights? I think if I put them back, plesk itself should symlink the Node versions and solve my npm problem, am I right?
 

Attachments

  • nodev.PNG
    nodev.PNG
    1.3 KB · Views: 4
also i have other errors after restore in .trash/node_modules/ folder can i delete these files?
 

Attachments

  • node2.PNG
    node2.PNG
    51.7 KB · Views: 4
  • nodev.PNG
    nodev.PNG
    38.3 KB · Views: 4
Calling of node related utilities should work over nodenv.
To ensure that node-related utilities are functioning properly, please check if you have the following files and directories in the home directory of your domain:
  1. /var/www/vhost/[youdomain]/.nodenv directory: This directory is essential for nodenv to manage different versions of Node.js.
  2. /var/www/vhost/[yourdomain]/.node-version file: This file specifies the Node.js version that should be used for your domain.
If either of these components is missing, it might cause issues with calling node-related utilities. Ensure that both the .nodenv directory and the .node-version file are present in the correct location.
You could use following commands to init nodenv if the directory or/and file are missing:
I realized that after the restore, the versions symlink expanded as a directory.
I didn’t quite understand about the eval "$(nodenv init -)" command, under which user should I execute it?
I have many subdomains inside /var/www/vhost/mydomain/ and there are different versions of nodejs, after i create a symlink if i run nodenv init as root will it affect other domains and nodejs applications?
shims directory is also empty now.
 
I didn’t quite understand about the eval "$(nodenv init -)" command, under which user should I execute it?

You should execute all the commands mentioned earlier under the context of the domain owner. For example, if you have a domain named "another.check" with the user "another.check_rkm9bjgnsx9", you would execute the commands as that user. The owner of the .nodeenv directory should also be "another.check_rkm9bjgnsx9". You can verify this by running ls command with following results:

# ls -lda /var/www/vhosts/another.check/.nodenv
drwxr-xr-x 3 another.check_rkm9bjgnsx9 psacln 4096 May 15 04:51 /var/www/vhosts/another.check/.nodenv

I have many subdomains inside /var/www/vhost/mydomain/ and there are different versions of nodejs, after i create a symlink if i run nodenv init as root will it affect other domains and nodejs applications?

Subdomains can share the same .nodeenv directory. However, they can still have different versions of Node.js because the version is determined by the contents of the .node-version file located in the root of each Node.js application. If your subdomains have different application roots, they can use different versions of Node.js based on their respective .node-version files.different versions of nodejs.

also i have other errors after restore in .trash/node_modules/ folder can i delete these files?

I believe this is some kind of nodejs modules for your application. Likely if they be missing, yarn re-install them.
 
Back
Top