Articles in this section

Node.js Run Script option fails on Plesk server: no node binary in the current PATH

Plesk for Linux kb: technical

Applicable to:

  • Plesk for Linux

Symptoms

  • Unable to start a Node.js application in Plesk using Run Script option in Domains > example.com > Node.js > Run Script

    CONFIG_TEXT: 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
    [...]

Cause

The node binary was not found by npm since it is missing on the specified PATH

Resolution

Via Plesk GUI - Single domain

Add scripts-prepend-node-path=true into .npmrc file in Node.js Application Root folder:

  1. Log in to Plesk GUI

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

  3. Click on [open] button next to the Application Root:
    mceclip0.png

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

    mceclip1.png

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

    mceclip3.png

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

    CONFIG_TEXT: scripts-prepend-node-path=true

Via SSH - Server level

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

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.