'npm install - don't authenticate

I am trying to install npm package using npm install {pacakge_name}

When using the npm install, npm will get my npm auth token from .npmrc. I want to install the package anonymously, or without authentication (for my own reasons) but I was unable to find a way to do so.

I have tried using env variables, but npm will first check if the npmrc is defined and will use it if so.

Is there a way (configuration or some flag I could use) that will allow me to install package without passing my npm auth token (without deleting the npmrc file)

Thank you!



Solution 1:[1]

Not sure there is built in support for that. You can achieve better isolation by running npm in a docker container.

docker run -v "$PWD":/usr/src/app -w /usr/src/app node:lts npm install {package_name}

Or if you just care about swapping out your npmrc just write a small shell function to rename the file before the command and replace it after the command.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1