Bobcares

Node.js Run Script option fails in plesk | Resolved

by | Dec 16, 2022

Wondering how to resolve Node.js Run Script option fails in plesk ? Our server management services team is here to lend a hand with your queries and issues.

Node.js Run Script option fails in plesk

Typically, error looks as shown below when you are using Run Script option in Domains > example.com > Node.js > Run Script:

start
> app-service-hello-world@0.0.1 start /var/www/vhosts/example.com/httpdocs
> node index.js
npm WARN lifecycle npm is using /opt/plesk/node/12/bin/node but there is no node binary in the current PATH. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with.
sh: node: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
[…]

Issue occurs if the node binary was not found by npm since it is missing on the specified PATH

How to resolve Node.js Run Script option fails in plesk?

Today, let us see the steps followed by our Support techs to resolve it:

1. Log in to Plesk GUI

2. Then, Go to Domains > example.com > Node.js

3. Next, click on [open] button next to the Application Root:

4. The Plesk File Manager will be opened, create a file by clicking on mceclip2.png > Create File.

5. Set the File name to .npmrc and click OK to create the file.

6. Click on the file .npmrc recently created, add the following content and click Save to apply the changes:

scripts-prepend-node-path=true

Via SSH – Server level

Let us see how to resolve Node.js Run Script option fails

Add the variable into a global npm config file:

Note: The following example shows how to configure the variable in NodeJS 12.4 version

  1. Connect to the server via SSH
  2. Create the etc directory in /opt/plesk/node/12/:# mkdir /opt/plesk/node/12/etc
  3. Create the file nmprc file with the following configuration:# echo “scripts-prepend-node-path=true” >> /opt/plesk/node/12/etc/npmrc

Conclusion

To wrap up, our Support Engineers demonstrated a quick fix for resolving Node.js Run Script option fails . We also learned about the root cause behind this specific error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.