如何更新咖啡脚本?

如何更新咖啡脚本?

当我尝试通过 观看咖啡脚本时出现以下错误coffee -o js -cw coffee

/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:321
        throw e;
              ^
Error: watch Unknown system errno 28
    at errnoException (fs.js:636:11)
    at FSWatcher.start (fs.js:663:11)
    at Object.watch (fs.js:691:11)
    at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:287:27
    at Object.oncomplete (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:100:11)

我不知道错误出了什么问题。

然后我检查了版本,coffee -v是 1.6.1 和node -vv0.6.12。

根据官方网站(http://coffeescript.org/) 最新版本是 1.6.3,所以我想coffee通过更新npm update -g coffee-script,但这也失败了。

npm WARN [email protected] package.json: bugs['name'] should probably be bugs['url']
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script

我如何更新咖啡脚本?

编辑 2013/10/11

在我的咖啡脚本目录中只有一个文件box_wrapper.coffee

$ ->
  $("body").children().wrap ->
    "<div id='#{$(@).attr "id"}_box' class='wrapper'/>"

编辑 2013/10/16

我尝试重新安装coffee,所以我这样做了。

$ sudo npm -g rm coffee
npm WARN Not installed in /usr/local/lib/node_modules coffee
$ coffee -v
CoffeeScript version 1.6.1

我无法删除coffee。我也尝试过这样的方法。

$ sudo apt-get remove npm
$ npm -v
-bash: /usr/bin/npm: No such file or directory
$ sudo apt-get install npm
$ npm -v
1.1.4
$ sudo npm -g install coffee

# I omit a lot of `GET` parts.

npm http 304 https://registry.npmjs.org/mkdirp/0.3.4
npm ERR! error installing [email protected]
npm http 304 https://registry.npmjs.org/assertion-error/1.0.0
npm http 304 https://registry.npmjs.org/growl
npm http 304 https://registry.npmjs.org/jade/0.26.3
npm http 304 https://registry.npmjs.org/diff/1.0.2
npm http 304 https://registry.npmjs.org/mkdirp/0.3.5
npm http 304 https://registry.npmjs.org/glob/3.2.1
npm http 304 https://registry.npmjs.org/ms/0.3.0
npm ERR! error rolling back [email protected] Error: UNKNOWN, unknown error '/usr/local/lib/node_modules/coffee/node_modules/express'
npm ERR! error installing [email protected]

npm ERR! EEXIST, file already exists '/usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules'
npm ERR! File exists: /usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules
npm ERR! Move it away, and try again.
npm ERR! 
npm ERR! System Linux 3.2.0-54-generic-pae
npm ERR! command "node" "/usr/bin/npm" "-g" "install" "coffee"
npm ERR! cwd /home/ironsand
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! path /usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules
npm ERR! fstream_path /usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules/___debug.npm
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EEXIST
npm ERR! message EEXIST, file already exists '/usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules'
npm ERR! errno {}
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:161:23
npm ERR! fstream_stack Object.oncomplete (/usr/lib/nodejs/mkdirp.js:34:53)

npm ERR! EEXIST, file already exists '/usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules'
npm ERR! File exists: /usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules
npm ERR! Move it away, and try again.
npm ERR! 
npm ERR! System Linux 3.2.0-54-generic-pae
npm ERR! command "node" "/usr/bin/npm" "-g" "install" "coffee"
npm ERR! cwd /home/ironsand
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! path /usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules
npm ERR! fstream_path /usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules/___debug.npm
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EEXIST
npm ERR! message EEXIST, file already exists '/usr/local/lib/node_modules/coffee/node_modules/mocha/node_modules'
npm ERR! errno {}
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:161:23
npm ERR! fstream_stack Object.oncomplete (/usr/lib/nodejs/mkdirp.js:34:53)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ironsand/npm-debug.log
npm not ok

并且npm-debug.log是一个空白文件。

答案1

问题是 npmjs 存储库没有 1.6.3,而是 1.6.1。我在这里假设,但错误的原因在于你的代码,而不是 CoffeeScript:

    } catch (e) {
      if (e.code !== 'ENOENT') {
        throw e;
      }
    }
  };

以上表明,如果e.code不完全相同,ENOENT则抛出错误,在您的情况下是:

Error: watch Unknown system errno 28
    at errnoException (fs.js:636:11)
    at FSWatcher.start (fs.js:663:11)
    at Object.watch (fs.js:691:11)
    at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:287:27
    at Object.oncomplete (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:100:11)

我会检查文件fs.js和/或恢复您对代码所做的最后更改。CoffeScript 运行良好,问题出在其他地方。


对于可能实际更新 CoffeScript 的人来说

如果您确实想使用最新的 CoffeScript,那么安装它的方法是:

npm install -g http://github.com/jashkenas/coffee-script/tarball/master

这将安装最新的 CoffeScript,如果您想要 1.6.3 版本,那么您应该使用:

npm install -g http://github.com/jashkenas/coffee-script/tarball/1.6.3

将 替换1.6.3为您喜欢的 CoffeScript 版本。

答案2

出现该错误的原因是nodejs版本太旧。Ubuntu 12.04、13.04 默认nodejs软件包是版本0.6.x

我更新了nodejs版本以v0.10.20适应这种情况,问题就解决了。

sudo apt-get update
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

我按照这里的指示进行操作。 https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

相关内容