I am currently trying to get into NodeJS together with the SailsJS framework. And I want to use coffeescript on the serverside aswell, but after converting all files in config/*.js
to config/*.coffee
properly with js2coffee, I get the following error when trying to start up the app:
config/400.coffee
SyntaxError: Unexpected token ILLEGAL
pointing to the first character in the file, which is a hashtag for a coffee comment. So it seems the app does not recognize the file as coffeescript, but searching for standard js instead.
I tried installing the package coffee-script
and requireing it in
app.js
require('coffee-script');
require('sails').lift(require('optimist').argv);
but it doesn't help.
If I delete 400.coffee
, the error appears in the next file 403.coffee
etc.
What am I doing wrong? Isn't coffeescript allowed in the config files or am I missing something?
Coffeescript 1.7.0, released Jan 28th, 2014, changed the require('coffee-script')
behavior to only load the compiler itself. Now, do load the automatic compiler for .coffee
files, you must call require('coffee-script/register')
before loading any coffeescript files.
Keep in mind that using this will mean that every .coffee
file will be recompiled every time you start node
, which could increase startup times. That may or may not be important to you though.
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.