emacs exec-path is not synced with $PATH under MacOS

I do not notice this issue when I try to use the npm from emacs eshell.
I found that the npm can be found from bash in iTerm2 but cannot be found from emacs eshell.
Then I notice that the emacs do not sync the interal PATH with what you can check from bash.

I fact the wiki already mentioned those issues here.
And also, you can find from the stackoverflow with the same question.

Here I want to tell a good package for emacs from stackoverflow:

With simple setup, you path could be right:

(require 'exec-path-from-shell)
(when (memq window-system '(mac ns))

Enjoy emacs.