Plesk

Unable to use NPM install for Node.js application in Plesk: usr/bin/env: ‘node’: No such file or directory

Symptoms

While attempting to deploy Node.js application in Domains > example.com > Node.js > NPM Install the following error occurred:

/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:
  • #EXTNODEJS-166 "The extension can now automatically update Node.js handlers even if files of previously installed Node.js handlers are locked."

    Fixed in:

Resolution

Please consider updating your server:

Workaround

If update is not possible for some reason you may try the following

workaround

  1. Connect to the server via SSH

  2. 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/python21,' -e '1s,^#!s*/usr/bin/envs+python($|s),#!/usr/bin/env python21,'