Symptoms
- Unable to start a Node.js application in Plesk using Run Script option in Domains > example.com > Node.js > Run Script
start
> [email protected] 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:
-
Go to Domains > example.com > Node.js
-
Click on [open] button next to the Application Root:
-
The Plesk File Manager will be opened, create a file by clicking on > Create File:
-
Set the File name to
.npmrc
and click OK to create the file: -
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
Add the variable into a global npm config file:
Note: The following example shows how to configure the variable in NodeJS 12.4 version
-
Connect to the server via SSH
-
Create the
etc
directory in/opt/plesk/node/12/
:# mkdir /opt/plesk/node/12/etc
-
Create the file
nmprc
file with the following configuration:# echo "scripts-prepend-node-path=true" >> /opt/plesk/node/12/etc/npmrc