Build Node. js integrated development environment Cloud9 and use the CoffeeScript plug-in

Source: Internet
Author: User
Node. js is a magic horse? To put it simply, it is a framework for implementing JavaScript running locally, including a js language interpreter (V8) and some class libraries. With it, you can use the js language to develop some local applications, so that js is not bound by the browser. Node. js uses the language interpreter and go... SyntaxHighlighter. all (Node. js is a magic horse? To put it simply, it is a framework for implementing JavaScript running locally, including a js language interpreter (V8) and some class libraries. With it, you can use the js language to develop some local applications, so that js is not bound by the browser.
Node. js uses the same efficient open-source engine V8 as google chrome.
About the entry of Node. js tutorials can refer to this book: "Node entry» a comprehensive Node. js tutorial", online address http://www.nodebeginner.org/index-zh-cn.html
For Node. js development, in addition to using traditional text editing tools such as Notepad ++ and vim, there is also an open-source IDE available, which is the Cloud9 IDE
Http://c9.io/
The unique feature of this development environment is that you can directly use a browser to complete development work on the cloud without installing something like node locally,
However, there are some restrictions on the use of official websites, such as free for open-source projects and third-party extensions.
This article describes how to build Cloud9 IDE on ubuntu 10.10.
First of all, Cloud9 (version 0.6) is built based on node 0.4.2. Although the current node (version 0.6.14) supports windows, many class libraries do not fully support windows,
So it will be smooth to build on linux.
Install git first and use it directly
[Plain]
Sudo apt-get install git
Then install nodejs and use
[Plain]
Sudo apt-get install nodejs
Install npm and use
[Plain]
Sudo curl http://npmjs.org/install.sh | sh
Create a folder in the user directory:
[Plain]
Mkdir cloud9
Run in cloud9
[Plain]
Git clone git: // github.com/ajaxorg/cloud9.git
More literary practices:
[Plain]
Git init
Git remote add origin git: // github.com/ajaxorg/cloud9.git
Git fetch master
Git checkout master
Then execute
[Plain]
Bin/cloud9.sh
The first execution will download a bunch of submodules. If the intermediate network is interrupted, you can use
[Plain]
Git submodule update
After downloading, these submodules are compiled, and libxml package prinstall Failed may occur,
Run the following command:
[Plain]
Sudo apt-get install libxml2-dev
After the final result is successful, it will be displayed as follows:

 


And automatically start the browser, open 127.0.0.1: 3000, enter the IDE Interface
Cloud9.sh can contain parameters. For more information, see cloud9.sh -- help.

[SQL]
Show this help message
-- Help
Load the configuration from a config file. Overrides command-line options. Defau
Lt:
-C, -- config
Run child processes with a specific group. Default:
-G, -- group
Run child processes as a specific user. Default:
-U, -- user
Activate debug-mode. Default:
-D, -- debug
Disable auto-open of the browser.
-S, -- silent
Define an action to execute after the Cloud9 server is started. Default:
-A, -- action
IP address where Cloud9 will serve from. Default: <127.0.0.1>
-L, -- ip
Port number where Cloud9 will serve from. Default: <3000>
-P, -- port
Path to the workspace that will be loaded in Cloud9 (may be relative or absolute
). Default: <.>
-W, -- workspace

The command line I used:
Bin/cloud9.sh-l 192.168.37.130-w ../mynode/-s
Specifically, you can specify a fixed ip address and a working directory. the browser is not automatically started.
After the startup is successful, you can access the website through other machines ,:


 


Shortcut Key: Ctrl + number, you can switch to the file in the editor, Ctrl + s to save the file, Ctrl + F5 is debug, Shift + F5 is stop, you can set vim mode in preferences and use vim to edit the source code (). In the following command line window, you can execute some server-side commands such as ls and git to facilitate source code management.

 


Use CoffeeScript:
JS uses a C/Java-like syntax style, while CoffeeScript uses a syntax similar to Ruby/Python,
It provides many benefits to make the script compilation work flexible and interesting, reducing the amount of code and so on,
For CoffeeScript, this book is worth reading (only 142 pages ):
CoffeeScript: Accelerated JavaScript Development URL: http://pragprog.com/book/tbcoffee/coffeescript


It is convenient to use Coffee in projects,
First, use npm to install CoffeeScript: npm install-g coffee-script
Run npm link coffee-script in the project directory.
Create a new coffee suffix script file test. coffee
Content: [javascript] hi =->
Arr = [1 .. 3]
Last = x for x in arr
Console. log "# {last }"
Module. exports. hi = hi
Hi =->
Arr = [1 .. 3]
Last = x for x in arr
Console. log "# {last }"
Module. exports. hi = hi


Create a new runner. js with the following content:
[Javascript] require ("coffee-script ");
Var test = require ("./test ");
Test. hi ();
Require ("coffee-script ");
Var test = require ("./test ");
Test. hi ();
Directly debug runner. js.


Integrate the livecoffee plug-in cloud9:
First, run the following command in the user directory:
[Plain] nickwar @ ubuntu :~ $ Git clone git: // github.com/tanepiper/cloud9-livecoffee-ext.git cloud9/client/ext/livecoffee
Nickwar @ ubuntu :~ $ Git clone git: // github.com/tanepiper/cloud9-livecoffee-ext.git cloud9/client/ext/livecoffee

Enter "ext/livecoffee" in Windows> Extension Manager> User Extensions and click Add to Add the plug-in.




 


Open the coffee file and select Edit-> LiveCoffee to display the corresponding js code window.




If you execute cloud9 on Windows 7, you need to download the node-builds folder to support, Code address: https://github.com/ajaxorg/node-builds
However, the socket. io seems to be faulty, but it is not successful yet .....
Error message:
Uncaught exception:
TypeError: Object # has no method 'server'
At new Manager (/cygdrive/d/Program Files/Cloude9/cloud9/support/socket. io/l
Ib/manager. js: 123: 10)
At Object. listen (/cygdrive/d/Program Files/Cloude9/cloud9/support/socket. io
/Lib/socket. io. js: 71: 10)



From NickWar's column

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.