简体   繁体   English

找不到模块(错误:找不到模块'./models/campground')

[英]Cannot find module (Error: Cannot find module './models/campground')

this is my code这是我的代码

var express     = require("express"),
app         = express(),
bodyParser  = require("body-parser"),
mongoose    = require("mongoose"),
Campground  = require("./models/campground"),
Comment     = require("./models/comment"),
seedDB      = require("./seeds")

this are my file's tree and when i run the above code, i get this error, Error: Cannot find module './models/campground' Require stack:这是我的文件树,当我运行上面的代码时,我得到这个错误,错误:找不到模块'./models/campground'需要堆栈:

 - /workspace/webDevBootcamp/yelpcamp/v4/app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/workspace/webDevBootcamp/yelpcamp/v4/app.js:5:19)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/workspace/webDevBootcamp/yelpcamp/v4/app.js' ]
}

Replace代替

Campground  = require("./models/campground"),

By经过

Campground  = require("./models/campgorund"),

Or change the filename "campgorund.js" to "campground.js".或者将文件名“campgorund.js”更改为“campground.js”。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM