Вопрос

I have a problem with sails 0.9.8. I already installed sails on my mac and also lift, it work well, but when start generate controller and model then start lift command again it show some error like:

$sails lift

/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/core/index.js:68
    var schemaAttributes = this.waterline.schema[this.identity].attributes;
                                                ^
TypeError: Cannot read property 'user' of undefined
    at _.extend._initialize (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/core/index.js:68:49)
    at module.exports (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/core/index.js:45:8)
    at module.exports (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/collection/index.js:57:8)
    at new child (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/extend.js:17:39)
    at instantiateCollection (/usr/local/lib/node_modules/sails/lib/hooks/orm/index.js:174:25)
    at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:108:13
    at Array.forEach (native)
    at _each (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:32:24)
    at Object.async.each (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:107:9)
    at Hook.startORM (/usr/local/lib/node_modules/sails/lib/hooks/orm/index.js:164:10)
    at Array.bound [as 1] (/usr/local/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
    at listener (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:462:46)
    at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:416:17
    at Array.forEach (native)
    at _each (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:32:24)
    at Object.taskComplete (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:415:13)
    at processImmediate [as _immediateCallback] (timers.js:330:15)
Это было полезно?

Решение

Based on the error you're getting from Waterline, it looks like a problem with your global Sails' dependencies. That's not the right version of Waterline for Sails 0.9.8. This can happen if you've been trying out other versions of Sails; the npm cache gets a little muddied-up. To correct it, do the following:

  1. sudo npm uninstall sails -g
  2. npm cache clear
  3. sudo npm install sails -g

That will reinstall Sails with all of the correct dependencies. You shouldn't have to change your project.

Другие советы

You may just be missing some modules. For example, if basic dependencies are installed globally with something like sudo npm install sails -g, newly generated Sails app will lift without any problems, but as soon as you start adding some functionality, it may required other modules (probably, DB adapter-related in your case).

Long story short, just run npm install from within your project folder, it will create a node_modules subfolder and install project's dependencies in it.

I saw this problem today. Reinstalling Sails globally didn't work for me because I had two copies of Sails installed. Deleting the locally installed copy forced Node to use the globally installed copy of Sails and all its dependencies which did fix everything.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top