i am a beginner in AWS, and I encountered this problem very early on. I created an EB environment and a code-pipeline in AWS. So whenever I push something to the repository, the app gets deployed. So for now I just have a "Hello world" node.js app, but I want to install the sharp npm dependency for later on. When I put the dependency in the package.json file and push it to the repo, a get the following error: error on deployment. I have done a lot of googling, and I think it has something to do with setting permissions to install the sharp dependency. However, none of the solutions I found have worked so far. If anything is unclear, I apologize and let me know :).
Asked
Active
Viewed 533 times
1
-
It's quite difficult to follow you on that one. You didn't provide enough details about the pipeline nor the process you did to set-up the Elastic Beanstalk environment. The more details you provide to reproduce the issue, the more likely it is to have an answer from someone. – iakko May 12 '22 at 16:06
-
Thanks for the feedback @iakko, the solution underneath solved it for me, but I will update the post for any future people with the same problem. :) – Jurij Dolenc Jun 01 '22 at 12:04
1 Answers
0
Please reference my "workaround" solution provided in the following GitHub Issue (Fails to install on AWS ElasticBeanstalk with node16 #3221) for a full explanation.
Solution:
- Create the following Platform Hooks paths in the root directory of your application bundle.
- .platform/hooks/prebuild
- .platform/confighooks/prebuild
- Create the following bash script (00_npm_install.sh) with execute permissions (chmod +x).
#!/bin/bash
cd /var/app/staging
sudo -u webapp npm install sharp
- Validate the Application Bundle Structure.
Ex. Sample project structure:
~/my-app/
├── app.js
├── index.html
├── .npmrc_bkp
├── package.json
├── package-lock.json
├── .platform
│ ├── confighooks
│ │ └── prebuild
│ │ └── 00_npm_install.sh
│ └── hooks
│ └── prebuild
│ └── 00_npm_install.sh
└── Procfile
- Deploy the Application!
Hope it helps!

jceduar
- 111
- 1
-
1Thank you so much!! I was working on this for way too long and this seems to be working! – Jurij Dolenc Jun 01 '22 at 11:59