Problems with installation permissions under webpack mac

  node.js, question

The installation of the webpack in the Mac environment failed (probably without permission), so the installation was carried out using sudo npm install webpack -g;

However, it is more troublesome to input sudo every time you use it in the future. what elegant solution is there?

Node is installed in the root directory. Please reinstall node. It is recommended to use nvm to manage node. Please refer to my article:Nvm management node under mac