Creating a new barebone NPM project on OSX

I completely forgot how to do this yesterday so I had to figure it out from scratch (Bouncing between technologies can do that to you, happens to the best of us! Haha!)

Anyways, fire up terminal and make a new folder and enter the following command to create a new directory for this app:

mkdir npmapp  

Enter the directory and initialise git for source control. This will download a .git file

git init  

You will require homebrew in order to use the next commands

I used homebrew to install wget since it doesn't exist on OSX, you could also run this functionality using curl but I prefer this approach, it's entirely up to you. Installing wget using homebrew

brew install wget  

Once homebrew has installed wget you can run the following command in the npmapp directory to download the required Node.gitignore file which will setup default ignore parameters for node projects and Github:

wget -O .gitignore  

After that run the following command to create a basic project:

npm init  

You'll be asked a lot of questions regarding the project you're creating which are totally subjective, just fill the info in or leave it as the defaults.

Finally commit an initial release to git using

git add .  
git commit -a 'Initial release'  

You can then start installing dependencies using

npm install --save [dependency_name]  

Hope this helps, just remember to commit changes to git as you continue so you have version control running on your projects


comments powered by Disqus