在 aws 上部署应用程序时在 package.json 中指定节点 js 版本
Posted
技术标签:
【中文标题】在 aws 上部署应用程序时在 package.json 中指定节点 js 版本【英文标题】:Specify node js version in package.json at time of application deployment on aws 【发布时间】:2022-01-11 10:47:12 【问题描述】:我是 node JS 的初学者。我一个月前就有了。使用 express 实现了一个基本的 rest API,它在我的本地主机中完美运行。
现在我尝试使用 eb CLI 在 AWS beanstalk 上部署它。 eb create 命令什么时候执行而不是它说的
2021-12-06 06:21:39 INFO Using elasticbeanstalk-us-east-2-187234582143 as Amazon S3 storage bucket for environment data.
2021-12-06 06:21:58 INFO Created target group named: arn:aws:elasticloadbalancing:us-east-2:187234582143:targetgroup/awseb-AWSEB-QB71GQAXNSNM/029cf54bd0029c58
2021-12-06 06:21:58 INFO Created security group named: sg-038e16d78bbbe7b2f
2021-12-06 06:22:14 INFO Created security group named: awseb-e-b3kg2ksm7c-stack-AWSEBSecurityGroup-1OKFQPW85UGII
2021-12-06 06:22:14 INFO Created Auto Scaling launch configuration named: awseb-e-b3kg2ksm7c-stack-AWSEBAutoScalingLaunchConfiguration-13VMAOEPR6RFV
2021-12-06 06:23:15 INFO Created Auto Scaling group named: awseb-e-b3kg2ksm7c-stack-AWSEBAutoScalingGroup-UVOBZD4IN60U
2021-12-06 06:23:15 INFO Waiting for EC2 instances to launch. This may take a few minutes.
2021-12-06 06:23:16 INFO Created Auto Scaling group policy named: arn:aws:autoscaling:us-east-2:187234582143:scalingPolicy:3251c481-2411-467a-ae3a-30725747c2a1:autoScalingGroupName/awseb-e-b3kg2ksm7c-stack-AWSEBAutoScalingGroup-UVOBZD4IN60U:policyName/awseb-e-b3kg2ksm7c-stack-AWSEBAutoScalingScaleDownPolicy-19YJB1MRW9A0
2021-12-06 06:23:16 INFO Created Auto Scaling group policy named: arn:aws:autoscaling:us-east-2:187234582143:scalingPolicy:74efad3a-9579-4d0e-ab38-5112deba1de8:autoScalingGroupName/awseb-e-b3kg2ksm7c-stack-AWSEBAutoScalingGroup-UVOBZD4IN60U:policyName/awseb-e-b3kg2ksm7c-stack-AWSEBAutoScalingScaleUpPolicy-IK6FQYMW5EEF
2021-12-06 06:23:16 INFO Created CloudWatch alarm named: awseb-e-b3kg2ksm7c-stack-AWSEBCloudwatchAlarmLow-9SQ05QBJTZP3
2021-12-06 06:23:16 INFO Created CloudWatch alarm named: awseb-e-b3kg2ksm7c-stack-AWSEBCloudwatchAlarmHigh-1N6M4CF239G1B
2021-12-06 06:23:31 INFO Created load balancer named: arn:aws:elasticloadbalancing:us-east-2:187234582143:loadbalancer/app/awseb-AWSEB-1M017GYW2YXTZ/01049b3c5b655b3b
2021-12-06 06:23:33 INFO Created Load Balancer listener named: arn:aws:elasticloadbalancing:us-east-2:187234582143:listener/app/awseb-AWSEB-1M017GYW2YXTZ/01049b3c5b655b3b/b2fc2089d35e2669
2021-12-06 06:23:37 INFO Instance deployment: You didn't specify a Node.js version in the 'package.json' file in your source bundle. The deployment didn't install a specific Node.js version.
2021-12-06 06:23:40 INFO Instance deployment completed successfully.
2021-12-06 06:24:47 INFO Successfully launched environment: Node-template-dev
环境健康状况也显示严重
我的 package.json 是
"name": "node-template",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts":
"start": "node ./index.js"
,
"author": "Chirag patel",
"license": "ISC",
"dependencies":
"express": "^4.17.1",
"nodemon": "^2.0.15"
,
"devDependencies":
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1"
【问题讨论】:
这能回答你的问题吗? How can I specify the required Node.js version in package.json? 不,我试过但不适合我。 【参考方案1】:如果您需要特定版本的 Node.js,则在使用 eb create
时需要使用 --platform
指定平台版本。例如:
$ eb create --platform "64bit Amazon Linux 2 v5.4.4 running Node.js 14"
【讨论】:
Elastic beanstalk 不允许使用此版本进行创建。 请尝试使用我更新的platform
参数。以上是关于在 aws 上部署应用程序时在 package.json 中指定节点 js 版本的主要内容,如果未能解决你的问题,请参考以下文章
使用 AWS Elastic Beanstalk 在 AWS 上部署 Spring Boot 应用程序
在 AWS Elastic Beanstalk 上部署 rails 应用程序