简体   繁体   English

SailsJS和Forever不适用于CoffeeScript

[英]SailsJS and Forever doesn't work with CoffeeScript

I have a SailsJS app, with much of it written in CoffeeScript. 我有一个SailsJS应用程序,其中很多是用CoffeeScript编写的。 When running it in Prod mode using "sails lift" all is good. 使用“风帆”在Prod模式下运行时,一切都很好。

Running it with forever doesn't work. 永远运行它是行不通的。 If I examine the logs, the problem seems to be with node running app.js 如果我检查日志,则问题似乎出在运行app.js的节点上

/var/www/obelix/api/models/Catalogue.coffee:2 attributes: ^ SyntaxError: Unexpected token : at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at /var/www/obelix/node_modules/sails/node_modules/include-all/index.js:96:53 at Array.forEach (native) at requireAll (/var/www/obelix/node_modules/sails/node_modules/include->all/index.js:40:9) at buildDictionary >(/var/www/obelix/node_modules/sails/lib/moduleloader/index.js:60:36) /var/www/obelix/api/models/Catalogue.coffee:2属性:^语法错误:意外令牌:位于Object.Module._extensions..js(module.js)的Module._compile(module.js:439:25) :474:10)在Module.load(module.js:356:32)在Function.Module._load(module.js:312:12)在Module.require(module.js:364:17)在require(模块.js:380:17)在/var/www/obelix/node_modules/sails/node_modules/include-all/index.js:96:53在Array.forEach(本机)在requireAll(/ var / www / obelix / node_modules /sails/node_modules/include->all/index.js:40:9)在buildDictionary>(/ var / www / obelix / node_modules / sails / lib / moduleloader / index.js:60:36)

Is it possible to get a sails+coffeescript app to run using node/forever? 是否有可能使Sails + Coffeescript应用程序使用节点/永远运行?

The problem is that coffee-script support doesn't work unless you're using sails lift . 问题是,除非您使用sails lift否则咖啡脚本支持将无法正常工作。 Try requiring coffee-script in your app.js file: 尝试在app.js文件中要求coffee-script:

// Start sails and pass it command line arguments
require('coffee-script');
require('sails').lift(require('optimist').argv);

Then npm install coffee-script --save 然后npm install coffee-script --save

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM