Getting Started (A How to on NodeJs, SailsJs and a Steem Project)

in #nodejs7 years ago

Assumptions

--Running ubuntu

--Basic understanding of terminal commands

--An interest in learning



Source

Getting Setup

Lets get our dependencies installed:

sudo apt-get install nodejs npm sublime-text git

Lets break out what each of these package are:

nodejs

This is a server architecture built on chromes javascript runtime,
that allows for robust and scale-able network application,
it is perfectly suited for realtime interaction.

npm

This is your node package manager, if you have used ruby on rails then think of your gems. If you have not then you can think of npm as your node tool box, it allows you access to all kinds of other community written application for node, as a matter of fact we are going to depend on some of those for our application.

sublime-text

Super powerful notepad++ like text editor, i really like this program and you don't have to use it but it does provide markup in most programming languages and gives you a nice sidepane for workspace management.

git

This program is likely one of the most powerful program in a developers utility belt in my opinion because it allows you to track versioning of your package, that way if you mess something you can roll back your progress to before you made the mistake, also as couple added bonuses it gives you great metrics on your work and also allows for easy collaboration between developers. We are going to be using git in conjunction with github.com so you will need to make a user account at github.com

Global Dependencies

Now that we have the other stuff dealt with we want to get some packages into node but we are actually going to require them globally for convenience.

npm install -g sails

We wanted global on this package because now we can run

sails new (REPLACE THIS WITH YOUR PROJECT NAME)

This will create new directory of the name you gave containing all of our programs operating files. Lets take a look at this:

cd (NAME OF PROJECT)

sublime-text .

one

Working in our project

Now we have sublime open with our new package in it. This has a lot of stuff in it but for now I want to focus on the package.json file let double click on that file and sublime will open it in our editor. This file communicates to node all of the things that we need for our project as well as some other important information like the name of the creator (YOU!)

Alright now I want to add a couple things to the dependencies in our project lets add these two lines to our package.json

"steem": "~0.4.2",
"steemconnect": "~0.0.33"

two

We have now told node that we need those two packages as well the version number may change depending on when you are using this guide so these package can be found here:

https://www.npmjs.com/package/steem
https://www.npmjs.com/package/steemconnect

Shoutout to ADCPM for providing both of these repos.

Please double check the most recent versions here and change as needed.

Don't forget to press CTRL S to save your package.json in sublime

three

Now we need to open a new terminal and navigate to our project main directory then run :

npm install

four

If you get an error about unexpected token double check that you have a comma after each of your dependencies in the package.json file.

Cleaning Up!

Excellent we can now see that our packages have been imported and we can now use those commands in our application. But for now we need to start pushing up to github so in the terminal in our project main directory lets type :

git init

git add .

git commit -am "Initial Commit."

Now lets head over to github.com and create a new repository:

five

And back in the terminal

git remote add (REPO NAME) (GITHUB ADDY)

git push godmode master --force

six

BAM we have now stored our initial commit to the repo.

seven

There are A LOT more operations that we can cover on this topic but for now this is where we will leave it, I hope you join me next time when we talk about adding user authentication to our app.

--Thank you for reading and thank you for your time.

Sort:  

Hey! Good job with this one. :)

Thanks man appreciate it.

Thanks for this. This is something I am interested in but haven't had time to really go look into.

My pleasure friend, let me know how it goes when you get a chance. Also I should mention once you have finished all these steps you can run your sails application with "sails lift" in the working directory then just browse to localhost:1337 and you will see your app.

I'll have to change some steps when/if I get around to this. I tend to use CentOS rather than Ubuntu simply because I work more with servers than desktop stuff, and my employers use CentOS.

Alright cool yea only a couple steps should need to be changed for that. Maybe document them if you get a chance :P

Coin Marketplace

STEEM 0.29
TRX 0.11
JST 0.031
BTC 68068.52
ETH 3873.47
USDT 1.00
SBD 3.64