将应用程序移至Debian服务器模型后无法访问Sails.js“ ReferenceError:未定义<model>”

时间:2018-12-13 22:33:24

标签: javascript node.js mongodb mongoose sails.js

将我的应用程序移至VPS后,我的应用程序停止工作。当我在浏览器中调用动作时,它将引发500错误'ReferenceError: <Model> is not defined'。 奇怪的是,无论是否在docker容器中运行它,它在Mac上仍然可以完美运行。模型被设置为可在globals.js中全局访问。

一个不起作用的控制器:

module.exports = {

  friendlyName: 'Players index',

  description: 'Lists all players in a table',

  inputs: {
  },

  exits: {
    success: {
      description: 'Renders index view',
      responseType: 'view',
      viewTemplatePath: 'pages/players-panel/index'
    },
    notFound: {
      description: 'No players was found in the database.',
      responseType: 'notFound'
    }
  },

  fn: async function (inputs, exits) {

    const models = await Players.find();

    if (!models) { return exits.notFound(); }

    return exits.success({players: models});
  }

};

模型:

/**
 * Players.js
 *
 * @description :: A model definition represents a database table/collection.
 * @docs        :: https://sailsjs.com/docs/concepts/models-and-orm/models
 */

module.exports = {

  attributes:{
    nickname: {type: 'string', required: true, unique: true},
    className: {type: 'string', required: true},
    team: {type: 'string', required: true},
    rank: {type: 'string'},
  },

};

0 个答案:

没有答案