Ошибка развертывания Heroku, работает локально, а не при развертывании - PullRequest
0 голосов
/ 04 марта 2019

Запустил "heroku run bash", а затем "npm start" и получил:

    internal/modules/cjs/loader.js:583
        throw err;
        ^
    
    Error: Cannot find module './Article'
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
        at Function.Module._load (internal/modules/cjs/loader.js:507:25)
        at Module.require (internal/modules/cjs/loader.js:637:17)
        at require (internal/modules/cjs/helpers.js:22:18)
        at Object.<anonymous> (/app/models/index.js:3:14)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Module.require (internal/modules/cjs/loader.js:637:17)
        at require (internal/modules/cjs/helpers.js:22:18)
        at Object.<anonymous> (/app/server.js:12:10)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! newsscrape@1.0.0 start: `node server.js`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the newsscrape@1.0.0 start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

вот содержимое моей модели.

Article.js

var mongoose = require("mongoose");

var Schema = mongoose.Schema;

var ArticleSchema = new Schema({
  // `title` is required and of type String
  title: {
    type: String,
    required: true
  },
  // `link` is required and of type String
  link: {
    type: String,
    required: true
  },
  excerpt: {
    type: String
  },
  // `note` is an array that stores a Note id
  note: [{
    type: Schema.Types.ObjectId,
    ref: "Note"
  }]
});

// This creates our model from the above schema, using mongoose's model method
var Article = mongoose.model("Article", ArticleSchema);

// Export the Article model
module.exports = Article;

Я не уверен, что проблема в том, что все написано правильно и локально работает просто отлично.Не уверен, почему он не находит модуль, когда все они находятся в папке модулей.

...