6

I'm reading this stackoverflow answer on running yo and npm without sudo by saving their results in ~/.node.

It uses echo prefix = ~/.node >> ~/.npmrc, and I'd like to know what each symbol means and how they work together in this case.

Community
  • 1
  • 1
randwa1k
  • 1,502
  • 4
  • 19
  • 30

1 Answers1

6
echo prefix = ~/.node

This simply prints a string to standard output. The shell will expand ~ to the value of $HOME, so the string printed might be something like "prefix = /home/randwa1k" (without the quotation marks, of course).

... >> ~/.npmrc

This redirects the output of the echo command to the file ~/.npmrc, which expands to the same thing as $HOME/.npmrc. Using >> rather than > means that the output is appended to the end of the file.

So the command as a whole appends one line of text to a file called .npmrc in your home directory.

The effects of that change to the .npmrc file are going to depend on whatever programs read that file.

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631