What is the earliest known written attempt at the definition of number? Is it Euclid's Elements?
A unit is that by virtue of which each of the things that exist is called one.
A number is a multitude composed of units.
This question seems simple, but the history of mathematics is a turbulent, tangled, mess. As Mauro said, it's hard to find sources that predate Euclid that provide "formal" definitions like we expect to have in modern times.
I am a physicist, so my impulse answer is that, "humans have always known what a number is as long as they have known that they had more than one finger." The fundamentals of mathematics are steeped in our experience as pattern seeking creatures. As a child, I always viewed numbers as a physical attribute of a physical object(s), rather than viewing them as abstract objects themselves. I think this is the prototype for humanity - only recently have we begun to view number in a "formal" manner.
With that said, it depends on what you mean by "number." This is tricky, you see, since the concept of "formality" in mathematics is debatable (https://en.wikipedia.org/wiki/Foundations_of_mathematics#Foundational_crisis).
So, in order to answer this, you have to be willing to be lenient about how you view formalism. A tallying system has no concept of place value, which limits its representation of large numbers, but a tallying system is still immensely useful and technically defines numbers in a relational manner. (Tallying systems are considered the first kind of abstract numbering system.) Prehistoric humans used tallying systems for thousands of years (https://www.amazon.com/Roots-Civilization-Cognitive-Beginnings-Notation/dp/1559210419).
As far as I can find, the first known system with place value was the Mesopotamian base 60 system (ca. 3400 BC) and the earliest known base 10 system dates to 3100 BC in Egypt. These systems are well before Euclid's time. In terms of "formalism," for one example, the ancient Egyptians had a formalism for rational numbers (https://en.wikipedia.org/wiki/Egyptian_fraction#Early_history).
Without generalizing too much, in the history of mathematics, geometric definitions usually precede algebraic (abstract) definitions. For example, Caspar Wessel and J.R. Argand provided geometric definitions of the complex plane before (I think) Cauchy provided the first algebraic (abstract) definition using functional analysis. (http://www.math.uri.edu/~merino/spring06/mth562/ShortHistoryComplexNumbers2006.pdf)
So, regardless of whether you want a geometrical or algebraic definition, Euclid was not the first, since his work was predated by other geometric definitions, and was not algebraically abstract.
(edit) I must also add that Bertrand Russell argued that Frege provided the first truely abstract definition of the concept of number, (https://people.umass.edu/klement/imp/imp.html#chapter2) see chapter 2. As always, Russell presents a compelling argument.