30

I'm trying to deploy a Node.js API with Elastic beanstalk.

I want to set the node command to start the app.

This is my nodecommand.config:

option_settings:
  aws:elasticbeanstalk:container:nodejs:
    NodeCommand: "npm start"

This is my file structure: enter image description here

Whenever I try to run eb deploy, I get this error:

2020-05-13 19:03:44    INFO    Environment update is starting.      
2020-05-13 19:03:48    ERROR   "option_settings" in one of the configuration files failed validation. More details to follow.
2020-05-13 19:03:48    ERROR   Unknown or duplicate parameter: NodeCommand 
2020-05-13 19:03:48    ERROR   Failed to deploy application.        

ERROR: ServiceError - Failed to deploy application.
Luke Schoenberger
  • 447
  • 1
  • 5
  • 7

3 Answers3

72

I just encountered this very same issue. Upon investigation I found that "NodeCommand" is the legacy way to run your application with custom commands.

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html

I removed the ".ebextensions" directory and added a file called "Procfile" to my source directory.

Inside Procfile, try putting the following:

web: npm start

Make sure you update your repository with these changes if necessary before trying to deploy.

Hope this helps!

Corey Rondeau
  • 736
  • 6
  • 5
  • 1
    Thanks. This helped a lot. The have contradictory information. Shouldn't it just be `npm start` though? – Luke Schoenberger May 14 '20 at 18:27
  • That's great to hear! I think npm start is referencing your scripts in package.json. So yes you should just do that if your "start" script has what you need. I am using an Express server to server my static React app files so I run it using node. – Corey Rondeau May 18 '20 at 18:23
  • This is actually exact solution. – Hassan Ali Shahzad May 21 '20 at 07:30
  • 28
    This worked. Shouldn't [this doc](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_express.html) be updated then? – ZeferiniX Jun 05 '20 at 09:37
  • 5
    I resolved this issue by removing the .ebextensions directory. I did not create a Procfile directory either. When you do not provide an Procfile ElasticBeanstalk will run `npm start` if you provide a package.json file. The [link](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html) above will provide some insight. – meddy Aug 26 '20 at 19:42
  • 1
    Thanks! AWS documentation is not up to date. – Dilip Agheda Sep 14 '20 at 11:02
  • https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-configuration-procfile.html – craigmichaelmartin Jan 21 '22 at 21:35
  • 7
    it's been >2 years and aws docs are still misleading people – Ask P Aug 20 '22 at 08:40
12

I used Procfile to deploy app

in Procfile

web: npm run deploy

In package.json, added new command deploy

 "scripts": {
    "deploy": "npm run build && npm run start"
  },
atazmin
  • 4,757
  • 1
  • 32
  • 23
1

For those who came here through Google, I had a similar problem and was getting this response:

ERROR: ServiceError - Configuration validation exception: Unknown or duplicate parameter: NodeVersion

After trying a lot of things I learned this is now legacy. I deleted that file and added a ProcFile at the root of my application (file name is case sensitive, there doesn't seem to be a required extension), with this line: web: npm start

That error disappeared (to be replaced by a different one about role permissions, but any progress is good progress, right?).

JEQP
  • 90
  • 6