npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Can I use environment or config variables in dependency git URL

I’ve Googled on this quite a bit but I’m coming up empty. I’m trying to have a protected dependency linked to as a git URL but don’t want to hard-code the password. I’d like to use an environment variable, but that doesn’t seem to work.

For example, instead of…

"dependencies": {
	"my-private-module": "git+https://node-module-user:sup3r-s3cr3t-k3y@my-git-server.local/my-private-module.git"

… I’d like to do …

"dependencies": {
    "my-private-module": "git+https://node-module-user:$node_module_key@my-git-server.local/my-private-module.git"

Unfortunately, npm install doesn’t seem to recognize environment variables in this context. Is there any way to do this?