Ensure npm install -g does not need sudo?

2019-09-06 01:29发布

问题:

On MacOS X an npm install -g requires a user to sudo, though we would like to have it so the 'global' mode is per user, rather than system wide. Does anyone know if this is possible? We would like to avoid exposing sudo to non-admin users.

回答1:

There appears to be an issue on this (currently marked closed at this time), on the NPM GitHub project. One person in the comment thread suggests:

I personally npm config set prefix ~/npm and have ~/npm/bin in my PATH



标签: macos npm sudo