Elastic Beanstalk + Laravel:由于旧的 NodeJS 版本 0.10 而无法运行 Gulp



我尝试在 AWS Elastic Beanstalk 上部署 Laravel 存储库。为此,我在 t2.medium 实例上创建了一个 PHP 环境,并使用 AWS CodePipeline 初始化了一个部署。

我需要在生产环境中运行npmgulp来创建我的静态资产,但不幸的是,由于安装了旧的 NodeJS 版本,我无法运行 NPM。这是0.10.46-1nodesource.el7.centos.

目前,我正在使用两个配置脚本来安装NodeJS 10.X,运行迁移并吞咽:

第一:

commands:
  01getNodeRepo:
    command: "curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -"
  02installNode:
    command: "yum install -y nodejs"
  03updateNpm:
    command: "npm install npm -g"
  04enableSudo:
    command: "echo Defaults:root \!requiretty >> /etc/sudoers"

第二:

container_commands:
  01artisanMigrate:
    command: "php artisan migrate --force"
  02showNodeVersion:
    command: "node -v"
  03showNpmVersion:
    command: "npm -v"
  04npmInstall:
    command: "sudo npm install"
  05gulp:
    command: "sudo ./node_modules/.bin/gulp --production"

以下是我的日志文件的摘录,其中显示 AWS EB 找到了两个nodesource存储库,并将使用旧版本:

[2019-01-01T19:32:23.008Z] INFO  [1535]  - [Application update code-pipeline-xx-xxx@17/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/xxxx/Command 02installNode] : Starting activity...
[2019-01-01T19:32:25.314Z] INFO  [1535]  - [Application update code-pipeline-xx-xxx@17/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild/xxxx/Command 02installNode] : Completed activity. Result:
  Loaded plugins: priorities, update-motd, upgrade-helper
  Repository nodesource is listed more than once in the configuration
  Repository nodesource-source is listed more than once in the configuration
  Resolving Dependencies
  --> Running transaction check
  ---> Package nodejs.x86_64 0:0.10.46-1nodesource.el7.centos will be installed
  --> Finished Dependency Resolution

任何想法如何强制环境使用新版本?谢谢!

知道了。这是解决方案:https://github.com/nodesource/distributions/issues/421#issuecomment-318560799

rm -f /etc/yum.repos.d/nodesource-el.repo
yum clean all
yum -y remove nodejs
yum -y install nodejs

最新更新