【问题标题】:Elasticbeanstalk npm: command not foundElasticbeanstalk npm:找不到命令
【发布时间】:2021-12-18 10:57:30
【问题描述】:

我的项目已经运行了 2 年,没有任何问题。 但是今天早上,它变成了返回错误。

sudo: npm: command not found

这是我的 .ebextensions 文件 我正在使用带有 PHP 的 Amazon Linux 2。

option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: COMPOSER_HOME
    value: /root

  # Point the app root to the public/ folder.
  - namespace: aws:elasticbeanstalk:container:php:phpini
    option_name: document_root
    value: /p

    ublic
    
      # Set here your php.ini `memory_limit` value.
      - namespace: aws:elasticbeanstalk:container:php:phpini
        option_name: memory_limit
        value: 256M
    
    container_commands:
      00_copy_env_file:
        command: "mv /tmp/.env /var/app/staging/.env"
      01_install_composer_dependencies:
        command: "sudo php /usr/bin/composer.phar install --no-dev --no-interaction --prefer-dist --optimize-autoloader"
        cwd: "/var/app/staging"
    
      02_install_node_dependencies:
        command: "sudo npm install"
        cwd: "/var/app/staging"
    
      03_build_node_assets:
        command: "npm run dev"
        cwd: "/var/app/staging"
    
      04_link_storage_folder:
        command: "php artisan storage:link"
        cwd: "/var/app/staging"
    
      05_run_migrations:
        command: "php artisan migrate --force"
        cwd: "/var/app/staging"
        leader_only: true
    
      06_run_migrations:
        command: "php artisan key:generate"
        cwd: "/var/app/staging"
    
      07_run_migrations:
        command: "php artisan passport:install"
        cwd: "/var/app/staging"

AWS 上的 elasticbeanstalk 有什么变化。我的配置有什么问题?

今天早上我所有的网站都同时关闭了。

编辑:

.platform/hooks/prebuild/install_latest_node_js.sh 文件如下。

#!/bin/sh

# Install Latest Node

# Some Laravel apps need Node & NPM for the frontend assets.
# This script installs the latest Node 12.x alongside
# with the paired NPM release.

sudo yum remove -y nodejs npm

sudo rm -fr /var/cache/yum/*

sudo yum clean all

curl --silent --location https://rpm.nodesource.com/setup_12.x | sudo bash -

sudo yum install nodejs -y

# Uncomment this line and edit the Version of NPM
# you want to install instead of the default one.
# npm i -g npm@6.14.4

【问题讨论】:

  • 你之前是怎么安装npm的?
  • 我知道了, curl --silent --location rpm.nodesource.com/setup_12.x | sudo bash - 代码,位于 .platform/hooks/prebuild 文件夹中。
  • 你能 ssh 到 EB 实例并检查它是否仍然安装吗?

标签: npm amazon-elastic-beanstalk


【解决方案1】:

试试这个命令:

sudo apt-get install npm

【讨论】:

    猜你喜欢
    • 2016-02-08
    • 2017-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-19
    • 2017-12-19
    相关资源
    最近更新 更多