Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what do lines starting with double-slash '//' mean in a .npmrc?

Tags:

node.js

npm

I'd naively assumed that .npmrc lines with double slash ('//') indicate a comment, but that's clearly not the case, because when I delete them, I'm unable to publish to my local registry.

Example:

registry=https://npm.myregistry.io/
//[email protected]
//npm.myregistry.io/:_authToken="Pgwb34F123EQdHqE7OoZA=="

If I remove the above // lines, publish results in

npm ERR! code ENEEDAUTH
npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`

I can't find any reference to this syntax in npmrc documentation or the ini module parser documentation. I'm assuming it has something to do with synthesized properties?

like image 595
Jolly Roger Avatar asked Nov 12 '18 18:11

Jolly Roger


People also ask

What does double forward slash mean in file path?

If, as part of a file transfer, you specify a file located on a Connect:Direct® node by using a file path that starts with a double forward slash (//), the file is treated as a data set.

How do I comment out lines in Npmrc?

Comments. Lines in . npmrc files are interpreted as comments when they begin with a ; or # character. .

What is Npmrc file used for?

Per-project config file npmrc file in the root of the project (ie, a sibling of node_modules and package. json ) will set config values specific to this project. Note that this only applies to the root of the project that you're running npm in. It has no effect when your module is published.


1 Answers

// has no special meaning in .npmrc or any other .ini file.

The ini syntax is key = value. So in this case the key is //npm.myregistry.io/:_authToken.

This is a Protocol-relative URL, meaning an URL that will take the protocol automatically from the current page (you can actually type //google.com in the browser, and it should take you to https://google.com)

Note that this may not necessarily be the URL used by npm for authentication. It's just a format chosen by the developers to hold the authToken (or other values) in the same string with the registry URL.

like image 167
mihai Avatar answered Sep 18 '22 23:09

mihai