I'm on a project using a stack that includes PostgreSQL, NodeJS, SailsJS, and BackboneJS. I pulled the client and server repos from git and I navigate into the server for the project and try to run it:
sails lift
Then I get this error:
/Users/$USER/Documents/Code/$APP/config/adapters.js:39
host: mc.dbSettings.host,
TypeError: Cannot read property 'host' of undefined
Where mc is a var that is set to point to another mainConfig.js file using a require statement. Opening that file I see that dbSettings is defined as:
dbSettings: {
host: "localhost",
user: "_appName_",
password: "_password_",
dbName: "_appDB_"
},
and sails cannot initialize because there is no localhost, or it doesn't know what it is? Please help.
If you're require
ing a file and getting an "undefined" error trying to access its contents, it's possible you haven't exported the file contents properly. Your config file should look something like:
module.exports = {
dbSettings: {
host: "localhost",
user: "_appName_",
password: "_password_",
dbName: "_appDB_"
},
...
};
Note the module.exports
. If that's missing, or if it's namespaced (like module.exports.foo
) or if that dbSettings
object is nested inside something else, it won't work.
dbSettings is undefined
. So that must mean that it's not being found by SailJS. If you are using v.1.0 then you need to define your settings in connections.js
instead of adapters.js
. I'm assuming Sails will not be able to find your configuration otherwise.