我正在Plesk托管服务器上安装节点(17.3.0版(。我只是这个服务器的众多用户之一,我没有超级用户密码,nodejs应用程序应该在我管理的子域中运行。
我遵循此示例页中的说明。失败阶段是通过NPM安装依赖关系。
日志包含以下相关行:
npm WARN deprecated core-js@2.6.12: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
...
...
...
npm ERR! code 127
npm ERR! path /var/......../sandbox/helloworld/node_modules/core-js
npm ERR! command failed
npm ERR! command sh -c node -e "try{require('./postinstall')}catch(e){}"
npm ERR! sh: node: command not found
(我不认为这个警告真的很重要,因为我以前在不会导致故障的情况下见过它。(
显然,节点可执行文件不在我的$PATH中,但这个安装是由Phusion Passenger管理的(据我所知(我需要知道nodejs可执行文件部署在哪里,以便将其添加到$PATH中。
对于每个依赖项,我都使用最后一个可用的版本。
我设法找到了解决这个问题的方法。
在这个页面中,他们建议在.npmrc.中放入一个记录scripts-prepend-node-path=true
这解决了问题。作为一个很好的副作用,我现在可以在安装节点的日志中读取:/opt/plesk/node/<MAJOR_VERSION_NUMBER>/bin
。我在修改问题标题时把它放在这里,因为这很可能是Plesk安装/配置模式。