Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js

Viewed 19997

When I try to upload my Node.js project on Elastic Beanstalk I obtain the following error:

Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js.

However, I have the package.json in the main directory.

7 Answers

If you use eb cli, make sure you have git committed all the changes.

If you do zip and upload, make sure you don't zip the parent folder but selecting all files and zip.

You need to zip the build directory, to do so inside that directory you can zip -r upload.zip . (do not forget the dot at the end for current directory).

So in that directory you need to have your index.js or server.js as EB looks for how to run the app in the directory only and will not look into folders src, dist etc.

In my case i have found a wrong copy of the folder .elasticbeanstalk with inside another config.yml

example

root_project_folder 
    .elasticbeanstalk/
         config.yml
    public/
         .elasticbeanstalk/
              config.yml

and when I started the "eb deploy" command it failed because use the wrong public/ folder as a ROOT

removing the public/.elasticbeanstalk/ have resolved my issue Ciao

This can be the packaging issue. You will need to go inside the project and compress altogether as provided in the screenshot:

enter image description here

Related