EC2 Amazon Linux: Cannot use sudo after Node.js setup - make command missing

Background

I’m working on setting up a development environment on AWS EC2 with Node.js and MongoDB. After following a tutorial to configure everything, I ran into a weird issue where sudo stopped working properly.

The Problem

Everything was going smoothly until I tried to run the final installation step. When I attempt:

sudo make install

I get this error:

sudo: make: command not found

The strange thing is that sudo was working fine earlier when I was editing the sudoers file. After that point, it just stopped functioning correctly.

What I’ve Tried

Without sudo: I tried running the command without sudo and it seemed to compile for a few minutes, but ultimately failed at the end.

Checking paths: Running which npm shows /usr/local/bin/npm and which sudo returns /usr/bin/sudo, so both seem to be in the right place.

PATH variable: I modified my PATH as suggested in other solutions. Here’s what echo $PATH shows:

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/bin:/usr/local/bin:/opt/node/bin

Alternative installation: I also attempted the curl method but got permission errors:

curl http://npmjs.org/install.sh | sh

This resulted in:

npm ERR! Error: EACCES, permission denied '/usr/local/bin/npm'
npm ERR! Please try running this command again as root/Administrator.

Questions

  1. Why did sudo stop working after editing sudoers?
  2. How can I properly install npm on Amazon Linux?
  3. Should I be using the ec2-user account or root for this?

Any help would be greatly appreciated. I’m fairly new to Linux administration and this has me completely stuck.

This is super common with fresh EC2 instances. Amazon Linux ships with a bare-bones setup - no build tools like make included. Your sudo is working fine, but the system can’t find the make command because it’s not installed. For Amazon Linux 2, install the development tools package group. This gets you make, gcc, and other essential build utilities you’ll need. Those permission errors with the curl method? Same root cause - npm tries to compile native modules during installation and needs these build tools. About ec2-user vs root: stick with ec2-user and use sudo when you need elevated permissions. Running everything as root is a security risk and creates ownership headaches later when your apps can’t access root-owned files.

u might be missing some dev tools. try running sudo yum groupinstall "Development Tools", that should get make and anything else u need. sudo itself should be ok, just no make present.

Your error isn’t about sudo - you’re missing the make command entirely. Amazon Linux comes pretty bare-bones by default. I hit this exact issue when I set up my first EC2 dev environment. Just run sudo yum install make gcc gcc-c++ to get the basic build tools. Since you’re doing Node.js work, you might want the full development group instead. Once make’s installed, your sudo make install should work fine. Your PATH changes look good, and you’re right to stick with ec2-user + sudo instead of switching to root.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.