Seen 725 times in failed builds on Mokxi in the 30 days to November 16, 2026.
The message
What the Arduino IDE prints
Output window
sketch.ino:1:1: error: 'Servo' does not name a type
1 | Servo gate;
| ^~~~~
exit status 1
Compilation error: exit status 1
It happens when a library is not included, when a statement sits outside every function, when a type is spelled with the wrong capital, and when a type is used above the line that defines it.
Mokxi's compiler, clang, words it as unknown type name 'Servo'.
Causes
The 4 usual causes with the fix
1A library class without its #include
Servo is a class that the Servo library declares. The sketch has to include the library before the first line that makes a Servo.
Between functions you can declare variables and objects. You cannot run a call. A line such as Serial.begin(9600); at the top of the file reads to the compiler like the start of a declaration, so it asks what type Serial is.
The compiler expected a type name and found a word it has no type for. Usually the library include is missing or a call was written outside a function.
Why does a missing #include give this error and not "file not found"?
Nothing is wrong with the include line you have. The include line you need is not there at all, so the compiler never learns the type exists.
Why does 'Serial' not name a type?
The line Serial.begin(9600); sits outside setup() and loop(). Move it into setup().