【问题标题】:node app with coffeescript and gulp带有咖啡脚本和 gulp 的节点应用程序
【发布时间】:2014-08-25 04:31:44
【问题描述】:

我对 node 还很陌生,但我正在尝试通过采用已经构建的框架 (skeleton) 并将其转换为咖啡脚本来深入研究。

所以这有一个配置文件夹,其中包含config.jspassport.jsutils.js 文件......显然,在根目录中,app.js。他正在使用 gulp,所以有一个gulpfile.js。我想将这些文件转换为咖啡脚本,而不仅仅是用户 js 文件。这是不好的做法吗?我已将 gulp-coffee 添加为 devDependency,并将咖啡脚本添加为依赖项。

重建上述文件并重命名它们...

[12:23:40] 'coffee' errored after 61 μs
[12:23:40] Error: Invalid glob argument
  at Gulp.src (/Users/brett/Dropbox/Apps/mean_projects/skeleton/node_modules/gulp/node_modules/vinyl-fs/lib/src/index.js:17:11)

... and further down

[gulp] [nodemon] starting `coffee --debug app.coffee`
/Users/brett/Dropbox/Apps/mean_projects/skeleton/config/config.coffee: line 1, col 1, Expected an assignment or function call and instead saw an expression.
/Users/brett/Dropbox/Apps/mean_projects/skeleton/config/config.coffee: line 1, col 13, Missing semicolon.
/Users/brett/Dropbox/Apps/mean_projects/skeleton/config/config.coffee: line 3, col 1, Expected an identifier and instead saw '#'.

这显示config.coffee,并且我从 js 转换为咖啡的每个文件(app、app_cluster、gulpfile、utils、passport 等)都有错误块。

任何有关该主题的帮助都会很好...我已经阅读了很多文章(有些讨厌咖啡脚本),但没有任何内容真正说明如何处理这个问题。

【问题讨论】:

    标签: javascript node.js coffeescript gulp


    【解决方案1】:

    如果您使用 gulp 3.7+,则 gulpfile.coffee 支持开箱即用。无需进行任何额外设置。

    如果您必须使用早期版本,您可以引导 coffeescript,只需将其放入其中即可:

    // Note the new way of requesting CoffeeScript since 1.7.x
    require('coffee-script/register');
    // This bootstraps your Gulp's main file
    require('./Gulpfile.coffee');
    

    然后你可以把你设置在 gulpfile.coffee 中。

    这是你的意思吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-22
      • 1970-01-01
      相关资源
      最近更新 更多