我对Elastic BeanStalk AWS服务很陌生。我的应用程序包括两部分:后端-node.js,它服务于第二部分,即。客户端-React.js当然,为了从服务器运行静态客户端文件,我需要首先构建客户端文件。这正是我要在AWS中部署应用程序的目的-部署后,我想运行将触发npm install
和npm run build
的钩子。
在我的应用程序的根目录中,创建了.ebextensions
目录,并在其中放置了01_build.config
文件:
commands:
create_post_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_build_app.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
cd /var/app/current/client/
npm install
npm run build
但是,这会使AWS部署失败。 它是这样的:
Application update failed at 2020-04-03T10:47:31Z with exit status 127 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/post/99_build_app.sh failed.
/opt/elasticbeanstalk/hooks/appdeploy/post/99_build_app.sh: line 3: npm: command not found
/opt/elasticbeanstalk/hooks/appdeploy/post/99_build_app.sh: line 4: npm: command not found.
我在这里想念什么?