In order to demonstrate just how easy this all is I will break it down for you, assuming you have nothing installed. Here we go:
- Install Node JS and NPM
- Install Teleport:
sudo npm install teleport
Create a NPM app (I called mine frappuccino) using the command line:
mkdir frappucino cd frappucino npm init
At this point, you will go through a wizard to generate the package.conf file. It is just to provide metadata for your app, don’t worry too much about the answers, most of them are fine as they are. You can always edit it afterwards. For the ‘module entry point’ question I left it as default, and for the ‘where do your modules live’ I said ‘lib’ (this is standard, but not default). It actually guessed I was using a Git repo which I have in my home directory, which is not the repo I want to use, so I had to remove that reference afterwards. If you run it in a git repo, it will figure it out and use the info from that for the repository info. So if you want to do that, you should create the git repo first. After removing the incorrect repo info, my package.conf file looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
The other change I made was to add the “dependencies” config, which will ensure that Teleport is installed as a dependency. OK, there are now a couple of other files you need to create:
The index.html page. Mine looks like this:
Note the included teleport file (which npm will supply), and the application js file (which we will create next). Now create the /lib folder in the frappucino folder, and in it create a file called app.js. In it I have the following, as a test.
alert("Frappucino is the best!");
Ok, now you should have the following file structure:
frappucino/ index.html package.json lib/ app.js
Finally, to get npm to supply the dependencies, and register the app locally, type this within the ‘frappucino’ directory:
sudo npm link
I get some nice pink and green output with ‘npm ok’ at the end to let me know it worked.
Now, to run the app, do:
If all goes, well, it should say something like:
Teleport is activated: http://localhost:4747/frappucino
Now you can open another terminal window and type:
And you will see your app in all its glory (or lack thereof, such as in this case.. just an alert window. But its a start :).