Heroku部署错误,无法在本地部署

时间:2019-03-04 07:20:56

标签: javascript express heroku mongoose cheerio

运行“ 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;

我不确定问题出在哪里,所有内容的拼写是否正确,在本地是否正常。不确定为什么当它们都在modules文件夹中时,为什么找不到模块。

0 个答案:

没有答案