2

In my project I want to use a .npmrc file to point to a private repository. From the documentation for npmrc we read:

NOTE: Because local (per-project or per-user) .npmrc files can contain sensitive credentials, they must be readable and writable only by your user account (i.e. must have a mode of 0600), otherwise they will be ignored by npm!

unfortunately git is not honouring the file permission 0600.

So: how to store the .npmrc file in git?

scheffield
  • 6,618
  • 2
  • 30
  • 31

2 Answers2

3

As you found out you are right.

Git doesn't care about file permissions.

Git only stores two permissions (755 & 644), so your need of 600 is not "recognized" by git.

To override it im using a manual script from this site or this


umask

Umask is a process attribute containing permission bits that are removed from newly created files.

Git creates directories and executable files with mode 777, and non-executable files with 666, and your umask turns off some of those bits.

If you want default permissions to be 644 and 755, you set your umask to 022:

umask 022
Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
2

As of now npm in version 3.3.12 does not behave like the documentation suggests. It picks up the .npmrc file even though the permission is "only" 644.

scheffield
  • 6,618
  • 2
  • 30
  • 31