运行eb init时出现ServiceError:'express'非有效键值对,求解决方案
eb init Hey there! Let's sort out this eb init error you're seeing. That "not a valid key=value pair" message means AWS Elastic Beanstalk was expecting a configuration entry in the format key=value (or key: value in YAML), but instead got the raw string express which it can't parse. Here's exactly what to do to get eb init working:
Step 1: Rerun eb init and watch your inputs closely
The most common cause is a misstep during the interactive setup:
- When prompted to choose a platform, don't type
expressdirectly—Elastic Beanstalk doesn't have a dedicated "express" platform. Express is a Node.js framework, so pick the appropriate Node.js platform from the numbered list (e.g.,Node.js 18 running on 64bit Amazon Linux 2). Just enter the corresponding number, not the framework name. - If you were setting environment variables when the error popped up, make sure every entry follows the
KEY=VALUEformat (likePORT=3000), not just a standalone word likeexpress.
Step 2: Clean up invalid config in .elasticbeanstalk/config.yml
If you already tried initializing the project once, your local config file might have the bad express entry stuck in it:
- Open the
.elasticbeanstalk/config.ymlfile in your project root. - Look for any line that just says
express(no key, no equals sign/colon). Delete that line, or adjust it to a valid configuration. For example, if you meant to set the platform, it should look like:platform: Node.js 18 running on 64bit Amazon Linux 2 - Save the file and try
eb initagain.
Step 3: Bypass interactive prompts (optional)
If you want to avoid interactive input entirely, run eb init with the platform explicitly specified. Replace the platform string with the one matching your project's Node.js version:
eb init --platform "Node.js 18 running on 64bit Amazon Linux 2"
This skips the setup prompts and directly configures the correct Node.js platform for your Express app.
Step 4: Validate your config
After fixing things, run eb config to view your current Elastic Beanstalk configuration. Double-check that every entry uses valid key: value YAML format—no random standalone strings allowed.
If you're still hitting issues, feel free to share the content of your .elasticbeanstalk/config.yml file, and I can help spot any remaining problems.
内容的提问来源于stack exchange,提问作者fds

