De man npm
:
global mode:
npm installs packages into the install prefix at
prefix/lib/node_modules and bins are installed in prefix/bin.
local mode:
npm installs packages into the current project directory, which
defaults to the current working directory. Packages are
installed to ./node_modules, and bins are installed to
./node_modules/.bin.
Local mode is the default. Use --global or -g on any command to operate
in global mode instead.
Então, quando você usou o sinal -g
, estava usando npm
no modo global. Se você quiser usar o modo local, não use o sinalizador -g
.