webpack: command not found after npm install webpack -g

Install it globally

npm i -g webpack

If you will work with webpack, install webpack-dev-server too

npm i -g webpack-dev-server

After I Install this two command I also found errors when run the

webpack

command so I figure out the problem by changing the version of webpack so I Install

npm install [email protected]

and every thing work fine for me.

I recommend you first learn a bit about npm and then webpack. You will struggle a lot. but finally you will find the right destination.


Try this

echo $(npm config get prefix)/bin

you will get STRING, which should include to your .bash_profile such way

export PATH=$PATH:STRING