Suddenly nothing works. The only thing I did was adding a new file to the folder "controllers", and then removed it. What can be wrong? What does it mean?
node/last/test4/controllers/.DS_Store:1
^
module.js:311
throw err;
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:429:25)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at /Users/henrikpetersson81/node/last/test4/controllers.js:8:13
at Array.forEach (native)
at Object.oncomplete (node/last/test4/controllers.js:6:15)
controllers.js (nothing is changed in this file since it worked):
var fs = require('fs');
module.exports = function(app, service){
fs.readdir(__dirname + '/controllers', function(err, files){
if (err) throw err;
files.forEach(function(file){
var name = file.replace('.js', '');
require('./controllers/' + name)(app, service);
});
});
};
Its because Mac created a file .DS_STORE
(im assuming you used finder to create/delete the file :P )
Whats happening is a helper is automatically going through the controllers folder and including them. It's gone "Hey, here's this controller xyz, include it.", "Here's another controller called .DS_STORE, include it"
Node has included it and gone "Woah, what is this file contents? THis isn't javascript. In fact, I have no idea what to do. help help help! Throw fatal error because i cant compute what im supposed to do"
Just delete the .DS_STORE file :)