3

I'm building a Sails app, and suddenly it stopped working. I run sudo node app.js to start the app and an error is throwed on the terminal:

A hook (`userconfig`) failed to load!
error: Error: Invalid module: [object Object],(...)

I've tried to reinstall all the modules, but no luck on that. I've readed some questions, like here and here but it's not what I am looking for. I'll provide here my package.json file, in case someone need to read it:

{
    "name": "myapp",
    "private": true,
    "version": "0.0.1",
    "description": "my app description",
    "keywords": [],
    "dependencies": {
        "bcrypt": "~0.7.6",
        "ejs": "~0.8.4",
        "grunt": "0.4.2",
        "grunt-contrib-clean": "~0.5.0",
        "grunt-contrib-coffee": "~0.10.1",
        "grunt-contrib-concat": "~0.3.0",
        "grunt-contrib-copy": "~0.5.0",
        "grunt-contrib-cssmin": "~0.9.0",
        "grunt-contrib-jst": "~0.6.0",
        "grunt-contrib-less": "0.11.1",
        "grunt-contrib-uglify": "~0.4.0",
        "grunt-contrib-watch": "~0.5.3",
        "grunt-sails-linker": "~0.9.5",
        "grunt-sync": "~0.0.4",
        "include-all": "~0.1.3",
        "mqtt": "^1.0.8",
        "node-uuid": "^1.4.2",
        "passport": "^0.2.1",
        "passport-local": "^1.0.0",
        "rc": "~0.5.0",
        "sails": "~0.10.5",
        "sails-disk": "~0.10.0",
        "sails-mysql": "^0.10.11"
    },
    "scripts": {
        "start": "node app.js",
        "debug": "node debug app.js"
    },
    "main": "app.js",
    "repository": {
        "type": "git",
        "url": "my repo"
    },
    "author": "Me",
    "license": ""
}

Any help would be awesome... I provided the info I think it's necessary, but I'll provide more if needed.

EDIT: I've seen on more question here but not worked too.

Community
  • 1
  • 1
Ze Luis
  • 236
  • 2
  • 15
  • Just an advice: do not run node.js applications with sudo. If you want to use 80 port it is better to use proxy (like nginx or something else) – Boris Zagoruiko Feb 06 '15 at 17:20
  • Hi @GlenSwift. I run with sudo because my app is using the port 443 (I'm using https with a self-signed certificate for testing purposes). But I'll follow your advice. Thank you! – Ze Luis Feb 06 '15 at 17:22
  • About your question: it sounds like you have syntax error in one of your config files or modify paths to configs in .sailsrc. Please, check this. – Boris Zagoruiko Feb 06 '15 at 17:25
  • @GlenSwift I haven't changed any config files. But I'll ckeck that and answer with my feedback. – Ze Luis Feb 06 '15 at 17:40
  • @GlenSwift thank you! I've solved my problem. It was an config file named 'countries.json' that I added in my config folder. I removed that file and my app worked! May be an conflict with another config of Sails.js. But it is a strange behaviour, 'cause I've run previously the app with that file in config folder and worked like a charm. Please post an answer and I'll mark it as a solution! – Ze Luis Feb 06 '15 at 17:46

1 Answers1

2

Your application can not load configuration files for some reason. You probably have syntax error in one of configs, configuration data conflict or changed paths to configs in .sailsrc.

You should not have .json files in config directory. It seems like sails load each file from it and try to recognize it as a config module

Boris Zagoruiko
  • 12,705
  • 15
  • 47
  • 79
  • Once again, thank you! By the way, what is the best location for my .json files? I've setup 2 files to provide some basic configuration of my app, because it's some static data that does not have to be changed. – Ze Luis Feb 06 '15 at 18:08