SailsJS: A hook (`orm`) failed to load!

Frustrated-User

SailsJS is a new and impressive NodeJS framework, but “new” doesn’t come without frustrations in the world of development.

If you are running into the error:
A hook (`orm`) failed to load!

this may be caused by the fact that SailsJS is requiring validation fiesta of your connections defined in connections.js even if they aren’t being explicitly called or used.

connections.js

The following works fine:

someMongodbServer: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017
},
someMongodbTestServer: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017
},

The following errors upon executing the “sails lift” command. Notice I’ve changed and set an invalid port number in the second connection.


someMongodbServer: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017
},
someMongodbTestServer: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27018
},

Even though someMongodbTestServer is never explicitly applied to a waterline model definition, it will still error out when running “sails Learn lift” or “node app.js”. This is actually the right framework logic, but it is easy to overlook when you see that multiple connections are defined in connections.js by default pastillas viagra precio. For example, a dummy MySQL connection is defined yet SailsJS will not error out on lift. It looks like once an adapter is installed AND used somewhere in the code, all connections with that adapter are checked on lift. A request has been made to comment out all connections by default to avoid confusion.

Ready for the solution? Cody Stoltman and Travis Webb kindly pointed me to the SailsJS environment-specific configuration documentation at http://sailsjs.org/documentation/concepts/configuration#?environmentspecific-files-config-env. You’ll ultimately need to move connections into environment specific files like development.js and heroku.js in the config/env directory.

Good luck!