Search code examples
node.jsmacospermissions.profile

Issue with ~/.profile after fixing NPM permissions


Installed Node.js on OS X. Fixed the permissions (i.e. sudo required) issue by changing NPM's default directory (https://docs.npmjs.com/getting-started/fixing-npm-permissions see Option 2). However, after booting up commands like grunt are not available until I run source ~/.profile.

Any way to avoid this hassle?


Solution

  • Did the node/NPM setup create a ~/.bash_profile or ~/.bash_login file? if so, bash will source that instead of ~/.profile at startup. If this is the problem, there are a couple of ways to fix it:

    • Copy the contents of your ~/.profile file into ~/.bash_profile (or ~/.bash_login). You may also want to delete ~/.profile to avoid future confusion.

    • Add a command to ~/.bash_profile (or ~/.bash_login) to source ~/.profile as well:

      [ -f ~/.profile ] && source ~/.profile