Well, it's time for a trivial question but I really need a clarification about!
Let's say I have to evaluate
$$\frac{\text{d}}{\text{d}x}\ |f(x)|^n$$
Shall I have to reason by treating the function as
$$|f(x)|^n = \left(\sqrt{f(x)^2}\right)^n$$
and then it would be quite easy, or shall I try to apply, somehow, the same rule for the derivative of $|x|$ like?
$$D\ |f(x)|^n = n\ f(x)^{n-1}\frac{|f(x)|}{f(x)}f'(x) = n\ f(x)^{n-2}|f(x)|f'(x)$$
Thank you for the clarification!
The biggest issue is that the function $y \mapsto |y| = \sqrt{y^2}$ is of course not differentiable when $y = 0$. Given this, we can only take the derivative of $|f(x)|^n$ on all points where $f(x) \ne 0$.
But as long as we are at $x$ where $f(x) \ne 0$, either of your two proposed methods will work. We have on the one hand \begin{align*} \frac{d}{dx} |f(x)|^n &= \frac{d}{dx} [f(x)^2]^{n/2} \\ &= \frac{n}{2} [f(x)^2]^{\left(\tfrac{n}{2} - 1\right)} \left[2f(x)f'(x)\right]. \\ &= n \cdot f(x) \cdot f'(x) \cdot |f(x)|^{n-2} \end{align*} and on the other hand \begin{align*} \frac{d}{dx} |f(x)|^n &= n |f(x)|^{n-1} \left[\frac{d}{dx} |f(x)|\right] \\ &= n |f(x)|^{n-1} \frac{f(x)}{|f(x)|} f'(x) \\ &= n \cdot f(x) \cdot f'(x) \cdot |f(x)|^{n-2}. \end{align*} where we used $\frac{d}{dy} |y| = \frac{y}{|y|}$.
You can now see that these two expressions are the same.
Note 1: In your calculations, I saw a couple of small typos or errors.
Note 2: We have to be careful dealing with the expression $[f(x)^2]^{n/2}$. Note this is not the same as $f(x)^n$. For a potentially negative $a$, we do not have that $(a^b)^c = a^{bc}$.