【问题标题】:Plesk + Phusion Passenger: core-js npm install fails - "npm ERR! sh: node: command not found"Plesk + Phusion Passenger:core-js npm 安装失败 - “npm ERR!sh: node: command not found”
【发布时间】:2022-01-26 13:36:22
【问题描述】:

我正在 Plesk 管理的服务器上安装节点(版本 17.3.0)。我只是这台服务器的众多用户之一,我没有超级用户密码,并且 nodejs 应用程序应该在我管理的子域中运行。

我正在遵循this sample page 的指示。失败的阶段是通过 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。

我正在为每个依赖项使用最后一个可用版本。

【问题讨论】:

  • 试试这个命令:which node ...那个命令应该告诉你node在哪里。
  • @MattOestreich - 来吧!我刚刚写了那个节点不在我的$PATH 上,因为它不是我安装的。你怎么能梦想用which找到它?

标签: node.js npm passenger plesk core-js


【解决方案1】:

我设法找到了解决此问题的方法。

this page 中,他们建议在.npmrc 中添加一条记录scripts-prepend-node-path=true

这解决了问题。作为一个很好的副作用,我现在可以读取安装节点的日志:/opt/plesk/node/&lt;MAJOR_VERSION_NUMBER&gt;/bin。 我在修改问题标题时将其放在这里,因为这很可能是 Plesk 安装/配置模式。

【讨论】:

    猜你喜欢
    • 2015-05-28
    • 2020-01-28
    • 2021-07-19
    • 2016-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-11
    相关资源
    最近更新 更多