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

时间:2019-01-02 09:26:09

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

我尝试在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

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

1 个答案:

答案 0 :(得分:0)

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