Getting started with developing Nodejs

6,557 views

Published on

An introduction to developing with Node.js and some useful tools to help the development and deployment processes. This talk was given at Asyncjs in Brighton

http://asyncjs.com/intro-nodejs

Published in: Technology
2 Comments
6 Likes
Statistics
Notes
No Downloads
Views
Total views
6,557
On SlideShare
0
From Embeds
0
Number of Embeds
3,153
Actions
Shares
0
Downloads
61
Comments
2
Likes
6
Embeds 0
No embeds

No notes for slide

Getting started with developing Nodejs

  1. 1. yet another talk on node.js getting started @philhawksworth
  2. 2. what we’ll look at whaddizit? installation options hello world modules & frameworks deploying & hosting comet and beyond
  3. 3. assumptionsweb development experience javascript knowledge unix, linux, osx not a nodejs ninja
  4. 4. whaddizit?
  5. 5. Evented I/O forV8 Javascript
  6. 6. evented i-what now? c++ v8 javascript engine server-side javascript single event loop non-blocking
  7. 7. useful knowledge strong javascript jQuery patterns
  8. 8. dangerous knowledge jQuery patterns
  9. 9. considerations how mature is it?v0.0.1: early 2009, currently v.0.4.8 who uses it? everyone is playing.
  10. 10. considerations how mature is it?v0.0.1: early 2009, currently v.0.4.8 who uses it? everyone is playing.should I be scared of it? no. but be cautious.
  11. 11. ball-ache: stability rate of change
  12. 12. installation options build from source package ndistro n
  13. 13. from source clone source from github install dependancies xcode toolsconfigure, make, make install
  14. 14. package
  15. 15. ball-ache: stability rate of change
  16. 16. many versionsmany versionsmany versions ndistro & n
  17. 17. ndistronode distribution toolkit
  18. 18. enables manyversions of node
  19. 19. http://github.com/visionmedia/ndistro
  20. 20. http://github.com/visionmedia/ndistro
  21. 21. local versionsfor each project
  22. 22. n
  23. 23. install as a module
  24. 24. ball-acheversion stabilitymodule stability
  25. 25. installing modules npmnode package manager
  26. 26. curl http://npmjs.org/install.sh | sh
  27. 27. $ npm install <package>
  28. 28. $ npm install n
  29. 29. $ npm install n@0.4.1
  30. 30. $ npm ls
  31. 31. !"# express@2.2.2$ !"# connect@1.3.0$ $ !"" mime@1.2.1$ $ %"" qs@0.1.0$ !"" mime@1.2.1$ %"" qs@0.1.0!"" n@0.4.1%"" underscore@1.1.6
  32. 32. !"# express@2.2.2$ !"# connect@1.3.0$ $ !"" mime@1.2.1$ $ %"" qs@0.1.0$ !"" mime@1.2.1$ %"" qs@0.1.0!"" n@0.4.1%"" underscore@1.1.6
  33. 33. $ npm update n
  34. 34. $ npm install n
  35. 35. $ npm update npm
  36. 36. n
  37. 37. while ndistro is for virtualenvironments
  38. 38. while ndistro is for localenvironments
  39. 39. n gives system widenode versioning
  40. 40. $ n 0.2.6$ n v0.3.3
  41. 41. downloadconfigure make install
  42. 42. $ n ls
  43. 43. $ n
  44. 44. 0.2.3 0.2.6 --debug 0.3.4 0.3.5ο 0.4.8
  45. 45. $ n use 0.4.8
  46. 46. what we’ll look at whaddizit? installation options hello world modules & frameworks deploying & hosting comet and beyond
  47. 47. hello world
  48. 48. app.js hello world
  49. 49. $ node app.js
  50. 50. $ ./bin/node app.js
  51. 51. $ n use 0.4.8 app.js
  52. 52. frameworks get a little help uri routing content negotiation templatingenvironment configuration
  53. 53. express the canonical webdevelopment framework http://expressjs.com
  54. 54. templatingmany ways to render your response
  55. 55. bootstrapping quick scaffolding
  56. 56. $ express --template --css --session
  57. 57. $ n use 0.4.8 app.js
  58. 58. deployingwhere do I put this thing? self-managed amazon, linode, slicehost managed heroku, no.de
  59. 59. duostack automated, git-based deployment install via npmmanage dependancies via npmlimited versions of nodejs
  60. 60. server.js hello world
  61. 61. $ git init$ git add$ git commit -m ‘1st commit’
  62. 62. $ duostack create nodedemo$ git push duostack master
  63. 63. Delta compression using up to 2 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 416 bytes, done.Total 3 (delta 0), reused 0 (delta 0)==== Duostack deploy received for nodedemo==== Compiling app... done Compressed size is 4.0KB==== Launching first instances.... done==== App successfully deployed to==== http://nodedemo.duostack.net
  64. 64. self-managedamazon, linode, slicehost
  65. 65. deploying get it there git configure it install dependenciesget it up, and keep it up upstart
  66. 66. $ git clone project.git$ cd project$ ndistro
  67. 67. ndistro is really just the shell
  68. 68. replicates your environment
  69. 69. keeping it up
  70. 70. $ /etc/init.d/
  71. 71. http://upstart.ubuntu.com/
  72. 72. what we’ll look at whaddizit? installation options hello world modules & frameworks deploying & hosting comet and beyond
  73. 73. easy comet requests websockets
  74. 74. cometlong-lived http requests
  75. 75. javascript on the client asks, and listensasks again, or takes action
  76. 76. websocketsmore efficient low latency comms
  77. 77. supported inmodern browsers
  78. 78. Graceful degradation
  79. 79. WebSocket Adobe Flash Socket Ajax long pollingAjax multipart streaming Forever Iframe JSONP Polling
  80. 80. but...node is not just for realtime
  81. 81. staying in the loopand finding out more
  82. 82. github wikigithub.com/joyent/node/wiki
  83. 83. ircirc.freenode.net #node.js
  84. 84. github wiki
  85. 85. @ryah@tjholowaychuk @isaacs @sh1mmer
  86. 86. ta!hawksworx.com@philhawksworth

×