【问题标题】:Compiled with `coffee` stopped working用“咖啡”编译停止工作
【发布时间】:2018-03-29 13:34:55
【问题描述】:

我不确定我做了什么,但我不能再编译 CoffeeScript 文件。无论我要编译哪个文件,我都会不断收到以下信息。我尝试通过运行sudo npm remove --global coffeescript 然后sudo npm install --global coffeescript 重新安装咖啡。在 Atom 中使用 coffee-compile 包的自动编译仍然有效。我该如何解决这个问题?

user@computer:~/some/path $ coffee -c code.coffee 
/usr/local/lib/node_modules/coffeescript/lib/coffeescript/command.js:23
  ({spawn, exec} = require('child_process'));
   ^

ReferenceError: Invalid left-hand side in assignment
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/coffeescript/bin/coffee:15:5)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

【问题讨论】:

    标签: node.js npm coffeescript


    【解决方案1】:

    您安装了 CoffeeScript 2+,它需要 Node 6 或更高版本;但是您的 Node 运行时为 ({spawn, exec} = 解构语法,Node

    【讨论】:

      【解决方案2】:

      在 Ubuntu 16.04.3 LTS 上得到了相同的结果,由

      修复
      $ sudo npm remove --global coffeescript
      $ sudo apt-get install coffeescript
      

      【讨论】:

      • 当我这样做时,我得到coffeescript is already the newest version (1.9.3~dfsg-1). 然后当我运行coffee -c code.coffee 时,我得到bash: /usr/local/bin/coffee: No such file or directory
      • 可能是您在 /usr/local/bin/ 中有损坏的符号链接吗?试试 /usr/bin/coffee -c code.coffee
      • 如果失败apt-get purge coffeescript 并重新安装。检查咖啡的实际安装位​​置 (dpkg-query -L coffeescript) 以及为什么 bash 在不同的地方寻找它
      • /usr/bin/coffee -c code.coffee 有效。我应该只是ln -s /usr/bin/coffee /usr/local/bin/coffee吗?
      • 是的,或者干脆删除断开的链接/usr/local/bin/coffee,那么bash应该选择正确的路径。
      猜你喜欢
      • 2011-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-25
      • 2013-01-03
      • 2012-07-31
      • 2014-06-04
      相关资源
      最近更新 更多