如何在没有 Rails 的情况下创建简单的 CoffeeScript 示例
我是咖啡脚本的新手。我在 Railscasts.com 上看到了一个 CoffeeScript 视频。从那一集我了解了如何将普通的Js和Jquery转换为coffeescript代码以及coffeescript的用法。
我正在尝试创建一个没有 Rails 的 CoffeeScript 示例。我浏览了 Coffeescript 网站。他们首先安装 Node.js。我尝试在windows和ubuntu中安装node.js,但失败了。我按照这个网站的说明进行操作:
http://howtonode.org/how-to- install-nodejs#ubuntu
对于 ubuntu,当我执行以下命令时,我收到“bash:./configure?:没有这样的文件或目录”错误
./configure
有人可以帮助我创建没有rails的简单coffescript示例吗?
另一件事 - 在 Mac 中“通过 homebrew 的帮助,我可以通过编译和显示 Js 窗口看到 coffescript 代码的编译 js”。 Windows 和 ubuntu 上有可用的选项吗?
I am new to coffeescript. I saw a coffeescript video in Rails casts.com. From that episode I understand how to convert the normal Js and Jquery to coffeescript code and the usage of coffeescript.
I am trying to create a coffeescript example without rails. I wetn through the coffeescript site. They first install Node.js. I tried to install node.js in windows and ubuntu, but I had failures. I followed the instruction as per this site:
http://howtonode.org/how-to-install-nodejs#ubuntu
For ubuntu I got "bash: ./configure?: No such file or directory" error when I execute the following command
./configure
Can anyone help me to create simple coffescript example without rails?
One more thing - In Mac "By the help of homebrew I can see the compiled js of coffescript code through compiled and Display Js window". Are there any options available in windows and ubuntu?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我敢打赌,在 Ubuntu 上安装 Node.js 最简单的方法是通过 APT:
它可能会得到一些过时的版本,但对于某些测试来说已经足够了。
如果您更喜欢最新版本(这是一个合理的偏好),我敢打赌从 dist 包安装 Node.js 会更容易。只需将其复制并粘贴到终端上即可:
此行将:
wget http://nodejs.org/dist/node-v0.5.0.tar.gz
tar zvxf解压下载的源代码node-v0.5.0.tar.gz
cd node-v0.5.0
进入源代码,使用./configure
设置构建参数,make
执行 Node.jssudo make install
安装构建的 Node.js&&
表示“执行下一个如果前一个命令成功则命令”(例如wget http://nodejs.org/dist/node-v0.5.0 .tar.gz && tar zvxf node-v0.5.0.tar.gz
表示我们将使用wget
下载该软件包,并且 成功后,我们将使用tar
解压下载文件。反斜杠 (\
) 允许我们将所有一系列命令分解为多行,因为默认情况下,我们会有一大行:然后,您可以安装 npm 使用这个简单的命令,可以在自己的
npm
github 页面 中找到:使用
npm
,它将安装 Coffee 太容易了,正如您在 CoffeeScript 页面:现在,只需运行您的测试:
看起来工作量很大吗?您可以在语言页面中尝试 CoffeeScript。只需单击“尝试 CoffeeScript”,就会出现一个控制台。
I would bet the easiest way to install Node.js on Ubuntu is through APT:
It probably will get some outdated version but it can be enough for some tests.
If you prefer the latest version (which is a reasonable preference), I bet it would be easier to install Node.js from the dist package. Just copy and paste this on terminal:
This line will:
wget http://nodejs.org/dist/node-v0.5.0.tar.gz
tar zvxf node-v0.5.0.tar.gz
cd node-v0.5.0
./configure
make
sudo make install
The
&&
means "execute the next command if the previous command succeeds" (for examplewget http://nodejs.org/dist/node-v0.5.0.tar.gz && tar zvxf node-v0.5.0.tar.gz
means that we will download the package withwget
and iff the download succeeds we will unpack the download file withtar
. The backslashes (\
) are here for allowing us to break all the series of commands in more than one line because, by default, we would have a big line:Then, you can install
npm
with this simple command, found in the ownnpm
github page:With
npm
, it will be too easy to install coffee, as you can see in the CoffeeScript page:Now, just run your tests:
Does it look like to much work? You can try CoffeeScript in the language page. Just click in "Try CoffeeScript" and a console will appear to you.
出于测试和演示的目的,直接在浏览器中编译 CoffeeScript 可能就足够了。您可以将 CoffeeScript 编译器和您的代码包含在标签中。
但这种方法效率不高,所以请使用它来玩一玩。
请参阅本节了解如何设置:
"text/coffeescript" 脚本标签
祝你好运!
For testing and demo purposes it may be sufficient to have your CoffeeScript compiled directly in browser. You can include the CoffeeScript compiler and your code in a tag.
This method is not efficient though so please use it for playing around.
Please see this section on how to set things up:
"text/coffeescript" Script Tags
Good luck!
Ubuntu 11.10 有一个最新的 CoffeeScript 软件包< /a>.
Ubuntu 11.10 has an up-to-date package for CoffeeScript.