简体   繁体   中英

SailsJS and Forever doesn't work with CoffeeScript

I have a SailsJS app, with much of it written in CoffeeScript. When running it in Prod mode using "sails lift" all is good.

Running it with forever doesn't work. If I examine the logs, the problem seems to be with node running 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)

Is it possible to get a sails+coffeescript app to run using node/forever?

The problem is that coffee-script support doesn't work unless you're using sails lift . Try requiring coffee-script in your app.js file:

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

Then npm install coffee-script --save

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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