【问题标题】:Can't install laravel-echo-server with npm and .ebextensions (code ELIFECYCLE)无法使用 npm 和 .ebextensions 安装 laravel-echo-server(代码 ELIFECYCLE)
【发布时间】:2020-04-20 05:07:34
【问题描述】:

错误背景

我正在启动一个 EC2 实例(Linux PHP 平台)。在构建过程中,我成功安装了 npm 以及一个不相关的包 PM2。

但之后它会尝试使用npm i -g laravel-echo-server 安装 laravel-echo-server 并且总是返回错误:

$ npm i -g laravel-echo-server


 /usr/bin/laravel-echo-server -> /usr/lib/node_modules/laravel-echo-server/bin/server.js

  > spawn-sync@1.0.15 postinstall /usr/lib/node_modules/laravel-echo-server/node_modules/spawn-sync
  > node postinstall

  npm ERR! code ELIFECYCLE
  npm ERR! syscall spawn sh
  npm ERR! file sh
  npm ERR! path sh
  npm ERR! errno -2
  npm ERR! spawn-sync@1.0.15 postinstall: `node postinstall`
  npm ERR! spawn sh ENOENT
  npm ERR!
  npm ERR! Failed at the spawn-sync@1.0.15 postinstall script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

尝试解决

奇怪的是,当我在构建后通过 SSH 连接到实例并自己运行命令时,它完全可以正常工作。只有当 .ebextensions 构建尝试调用它时才会失败。

npm config set scripts-prepend-node-path true  #to make sure it has the right node path
sudo ln -s `which nodejs` /usr/bin/node        #to create a sym link to the node location
sudo ln -s /usr/bin/node /usr/bin/nodejs       #another attempt to create a sym link to the node location

附加信息

.ebextensions 脚本

sudo yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_13.x | sudo -E bash -
sudo yum install -y nodejs
npm install -g pm2@latest
npm install -g laravel-echo-server

哪个节点

/usr/bin/node

哪个nodejs

not found    #or /usr/bin/nodejs if I create the symlink, but that doesn't help

哪个 pm2

/usr/bin/pm2

【问题讨论】:

    标签: node.js linux npm amazon-ec2


    【解决方案1】:

    显然这是生成同步的问题,所以我将其更改为这个并且它成功地工作了:

    npm i -g laravel-echo-server --ignore-scripts spawn-sync
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-08
      • 2020-02-20
      • 1970-01-01
      • 2018-10-29
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      相关资源
      最近更新 更多