npm ERR! [email protected] install: `node-gyp rebuild`

8.9k Views Asked by At

I am new to AWS ec2 instance, I have tried to host my server code on ec2 I have done my instance setup successfully based on the following reference from "https://ourcodeworld.com/articles/read/977/how-to-deploy-a-node-js-application-on-aws-ec2-server". On the ec2 ubuntu server, I am getting "npm ERR! [email protected] install: node-gyp rebuild" error when I install node-modules using npm I cmd. I have tried many examples from StackOverflow no one solved my issue. The error message is following below

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2020-10-03T15_56_49_786Z-debug.log
2

There are 2 best solutions below

1
On

If you're using recent macOS or macs they use Catalina. In that case, use these guidelines to use gyp in macs:

https://github.com/nodejs/node-gyp/blob/main/macOS_Catalina.md

this solved the err for me

0
On

This issue bugged me after updating to the macOS Monterey. It could be issue with the python and python version. so check in logs if it is python version not found or mismatch. If the scenario matches then follow below steps:-

$ brew install pyenv
$ pyenv install 3.10.3
$ pyenv global 3.10.3

# Add pyenv to your PATH so that you can reference python
$ echo "export PATH=\"\${HOME}/.pyenv/shims:\${PATH}\"" >> ~/.zshrc

# open a new terminal window and confirm your pyenv version is mapped
$ which python3
$ python3 --version
# Now try to re-run yarn install or npm install