Applicable to:
- Plesk for Linux
Symptoms
While attempting to deploy Node.js application in Domains > example.com > Node.js > NPM Install the following error occurred:
PLESK_ERROR: /usr/bin/env: ‘node’: No such file or directory
Cause
Product issues:
- #EXTNODEJS-169 Open
-
#EXTNODEJS-189 "Under certain circumstances, installation of the application packages no longer fails with the “node: not found” error."
Fixed in:- Node.js 2.1.0 06 April 2022
-
#EXTNODEJS-166 "The extension can now automatically update Node.js handlers even if files of previously installed Node.js handlers are locked."
Fixed in:- Node.js 2.0.1 09 September 2021
Resolution
Workaround
If update is not possible for some reason you may try the following
-
Connect to the server via SSH
-
Change the path affected in
/opt/plesk/node/12/lib/node_modules/npm/bin/npm-cli.js
and other files to the correct one. Below is an example for NodeJS 12:# find /opt/plesk/node/12 -type f -print0 | xargs -0 sed -i -e '1s,#!/usr/bin/env node,#!/opt/plesk/node/12/bin/node,g' -e '1s,^#!\s*/usr/bin/python($|\s),#!/usr/bin/python2\1,' -e '1s,^#!\s*/usr/bin/env\s+python($|\s),#!/usr/bin/env python2\1,'
In case the the node_modules directory also is present in /var/www/vhosts/example.com/node_modules replace find /opt/plesk/node/12 with /var/www/vhosts/example.com/node_modules
Comments
3 comments
find /opt/plesk/node/12 -type f -print0 | xargs -0 sed -i -e '1s,#!/usr/bin/env node,#!${2}/bin/node,g' -e '1s,^#!\s*/usr/bin/python($|\s),#!/usr/bin/python2\1,' -e '1s,^#!\s*/usr/bin/env\s+python($|\s),#!/usr/bin/env python2\1,'
=>
sed: -e expression #2, char 52: invalid reference \1 on `s' command's RHS
sed: -e expression #2, char 52: invalid reference \1 on `s' command's RHS
sed: -e expression #2, char 52: invalid reference \1 on `s' command's RHS
What would be the correct command?
@Henry C. Lavau try to edit the file /opt/plesk/node/12/lib/node_modules/npm/bin/npm-cli.js manually.
The file starts with:
#!/opt/plesk/node/12/bin/node
;(function () { // wrapper in case we're in module_context mode
// windows: running "npm blah" in this folder will invoke WSH, not node.
/* global WScript */
if (typeof WScript !== 'undefined') {
WScript.echo(
'npm does not work when run\n' +
'with the Windows Scripting Host\n\n' +
"'cd' to a different directory,\n" +
"or type 'npm.cmd <args>',\n" +
"or type 'node npm <args>'."
)
WScript.quit(1)
return
}
Thank you for your answer. I overcame the problem of installation I had for a package by installing Node 14.
Please sign in to leave a comment.