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
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:CONFIG_TEXT: scripts-prepend-node-path=true
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
Comments
5 comments
@... I don't have any npmrc file, and the "etc" directory doesn't exist. Do you want us to create it? Because if I create it, it seems to work.
Hi Paolo Gabrielli, Thank you for noticing that! The article was updated accordingly.
Hi
When you say «Create the file
nmprc
file», in fact you mean the «nmprc» file, right?So I
- created the «etc» folder
- created the «npmrc» file inside
- added the content «echo "scripts-prepend-node-path=true"» in the npmrc file
And I still get the error
Any idea?
Ok I solved my issue by adding a .npmrc file in the App root with this content
and not in
Hello, Sébastien Angot
> - added the content «echo "scripts-prepend-node-path=true"» in the npmrc file
echo was not needed in the file itself. The following command from the article creates appropriate file.
# echo "scripts-prepend-node-path=true" >> /opt/plesk/node/12/etc/npmrc
Please sign in to leave a comment.