如何更新咖啡脚本?

iro*_*and 5 npm

当我尝试通过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)
Run Code Online (Sandbox Code Playgroud)

我不知道错误是怎么回事。

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

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

npm WARN coffee-script@1.6.1 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
Run Code Online (Sandbox Code Playgroud)

如何更新咖啡脚本?

编辑 2013/10/11

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

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

编辑 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
Run Code Online (Sandbox Code Playgroud)

我无法删除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 express@3.2.6
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 express@3.2.6 Error: UNKNOWN, unknown error '/usr/local/lib/node_modules/coffee/node_modules/express'
npm ERR! error installing coffee@0.0.1

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
Run Code Online (Sandbox Code Playgroud)

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

Bra*_*iam 5

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

    } catch (e) {
      if (e.code !== 'ENOENT') {
        throw e;
      }
    }
  };
Run Code Online (Sandbox Code Playgroud)

以上表明 ife.codeENOENTthen 抛出错误不完全相同,在您的情况下是:

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)
Run Code Online (Sandbox Code Playgroud)

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


对于可能实际更新他们的 CoffeScript 的人

如果你真的想使用最新的 CoffeScript,那么安装它的方法是使用:

npm install -g http://github.com/jashkenas/coffee-script/tarball/master
Run Code Online (Sandbox Code Playgroud)

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

npm install -g http://github.com/jashkenas/coffee-script/tarball/1.6.3
Run Code Online (Sandbox Code Playgroud)

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


iro*_*and 5

由于旧nodejs版本而发生错误。Ubuntu 12.04、13.04 默认nodejs包是 version 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
Run Code Online (Sandbox Code Playgroud)

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