Can you show what you have actually done to get the error? Because this works:
julia> using Optim
julia> rosenbrock(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
rosenbrock (generic function with 1 method)
julia> result = optimize(rosenbrock, zeros(2), BFGS())
* Status: success
(...)
julia> result.minimizer
2-element Vector{Float64}:
0.9999999926033423
0.9999999852005353