【问题标题】:Elastic Beanstalk + Laravel: Can't run Gulp because of old NodeJS Version 0.10Elastic Beanstalk + Laravel:由于旧的 NodeJS 版本 0.10 无法运行 Gulp
【发布时间】:2019-05-28 22:58:03
【问题描述】:

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

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

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

第一:

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

有什么想法可以强制环境使用新版本吗?谢谢!

【问题讨论】:

    标签: node.js laravel amazon-web-services gulp amazon-elastic-beanstalk


    【解决方案1】:

    知道了。这是解决方案: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
    

    【讨论】:

      猜你喜欢
      • 2018-01-29
      • 2016-11-24
      • 2018-04-12
      • 2022-12-15
      • 2020-12-22
      • 2015-03-05
      • 2015-12-04
      • 2021-11-09
      • 2020-11-07
      相关资源
      最近更新 更多