Definition of degree of finite morphism plus context

If you want to talk of function fields, it is prudent to consider only finite dominant morphisms $f\colon X\to Y$ between (locally noetherian) integral schemes.
The degree of $f$ is then defined as the degree of the corresponding extension of function fields $n=[k(X):k(Y)]$.
Qing Liu in his wonderful book asks you to prove (Chapter5, Exercise 1.25) that if $f$ is flat, then all fibers $f^{-1}(y)$ of $f$ have $n$ points, if you count them suitably: $\dim_{k(y)}\mathcal O(f^{-1}(y))=n$ .

Warning: The result is always false if $f$ is not flat!
This is part of the exercise mentioned above.
For example if you normalize the node $N=V(y^2-x^2-x^3)\subset \mathbb A^2_k$, you obtain the finite morphism $$f\colon \mathbb A^1_k\to N\colon t\mapsto (t^2-1,t^3-t)$$ of degree $$[k(\mathbb A^1_k):k(N)]=[k(t):k(t^2-1,t^3-t)]=[k(t):k(t)]=1$$
However for the fiber over $P=(0,0)\in N$ you have $\dim_{k(P)}\mathcal O(f^{-1}(P))=2$ because $f^{-1}(P)$ consists of the two simple points $t=-1, t=+1$.


I just want to note that you don't need any finiteness condition on $f$ to define the degree. Any dominant morphism $f : X \to Y$ of integral schemes $X$ and $Y$ maps the generic point $x$ of $X$ to the generic point $y$ of $Y$, hence there is a canonical homomorphism $\mathscr{O}_{Y,y} \to \mathscr{O}_{X,x}$, which gives a field extension $R(Y) \hookrightarrow R(X)$. (Thanks for Georges Elencwajg for simplifying my original argument.)

So we don't need finiteness conditions on $f$, or on $X$ and $Y$, to talk about the field extension $R(Y) \hookrightarrow R(X)$ or its degree $\deg(f) = [R(X) : R(Y)]$. However if one wants to ensure this degree is finite, it suffices to assume $f$ is locally of finite type and

(i) $f$ is closed, the dimensions of $X$ and $Y$ are equal (see (Stacks, 02JX) and (Stacks, 02NX)),

or

(ii) $f$ is separated or quasi-compact (e.g. proper or even just universally closed), and there exists an affine open $V \subset Y$ such that the restriction $f^{-1}(V) \to V$ is finite (Stacks, 02NX).


Besides Adeel's nice answer, one can find another definition of the degree in case the morphism is flat and finite (and the schemes are locally Noetherian) in the Stacks project 02K9. This is actually the thing I hoped it would be, as I stated in the question.