I'm primitive in integrals and derivatives and I'm trying to solve the integral $\int \frac{1}{e^x}\,dx$, but especially this integral was hard to me to solve it.
So I tried:
$$\begin{align} \int\frac{1}{e^x}\,dx&=\int \frac{1}{\color{Red}{e^x}}\color{Blue}{e^x\,dx}\\&=\int \frac{1}{\color{Red}{u}}\,\color{Blue}{du}\\&=\ln\left(|u|\right)\\&=\ln \left(|e^x|\right)+C \end{align}$$
But my solution is wrong while I used the integration by substitution method ?!
Correct answer:
$$\begin{align} \int\frac{1}{e^x}\,dx&=\left(-e^{-x}\right)+C \end{align}$$

$$\int dx\frac{1}{e^x} = \int e^{-x}dx =$$ With substitution $y=-x$: $$=-\int e^ydy = -e^y +C = -e^{-x} +C$$
Your solution is wrong because the first step is wrong: $$\int dx\frac{1}{e^x}\neq \int dx\frac{1}{e^x}e^x$$ If you apply the substitution $u=e^x$ correctly you get: $$\int dx\frac{1}{e^x} = \int\frac{1}{u^2}du = -u^{-1}+C = -e^{-x}+C$$