Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript npm Basics (retiring) What is npm? Introducing npm

John Coolidge
John Coolidge
12,614 Points

npm/Node install on Ubuntu Linux

I'm installing npm and Node on Ubuntu and since I'm a complete newb to Linux/terminal (I've taken a course on the console on Treehouse a long time ago) I want to know if someone can expound on the link at the bottom of this video on installing npm/Node on my OS.

At the bottom of the link on installing to Linux it says I have to add three lines to my .bashrc file:

export PATH="$HOME/.linuxbrew/bin:$PATH" export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH" export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"

I've found the file and have edited it with Nano. It didn't say where to put these lines in the file so I've put them at the bottom. Is that sufficient? I don't want to screw up my Linux install by playing with the terminal too much before I have a better understanding of it.

Thanks!

The location isn't going to break anything, just as long as you don't modify any other entries.

2 Answers

Tom Geraghty
Tom Geraghty
24,174 Points

As Damien said, the location of your alias within the file isn't as important as remembering not to erase or modify any of the other aliases. You can get a feel for how the document is set up by reading it; e.g.: use # for comments and so on.

Another thing to be aware of: depending on what version of linux you have the file you're looking for might be .bash_aliases or .bashrc. I don't tend to mess with .bashrc and have been told to put all of my own aliases into the .bash_aliases file. You can find both of these in the home folder. In a terminal, type:

cd ~/
ls -al

Which should list a lot of files including .bashrc and .bash_aliases. From there use nano/gedit/less/sublime/atom/whatever text editor to edit the file and add those lines for the export path. I usually just put them at the bottom with a # comment stating what they are for in case you are reading it later and wondering why it's there. Don't sell future-you short by not commenting your code now!

If you know why you are doing something it can help you from messing something up, as well. The reason you are adding these lines is to create an alias to a program which you can then type without knowing the full directory path. So instead of having to type in the terminal something like:

~/directory/to/fake/program/program_file.extension target-file.extension

You can, using your alias, from anywhere in the terminal, just type:

program_file.extension target-file.extension

And it'll work. Awesome!

For future reference: It suffice to install npm. I am currently on Manjaro.

yes | sudo pacman -S npm

Installing npm will automatically install Node.js. I believe the same applies for Ubuntu.

sudo apt install npm