Closed Curtismn87 closed 9 years ago
Can you show the exact text of the error? My guess is that the path isn't correct. Maybe it should be ./db/connection
instead of ../db/connection
.
var express = require("express");
var router = express.Router();
var Stock = require("../db/connection").models.Stock;
Error: Cannot find module '../db/connection'
Error: Cannot find module './db/connection'
Error: Cannot find module '/db/connection'
Error: Cannot find module 'EVERYTHINGisBROKEN/db/connection'
Here is the exact error:
Error: Cannot find module '../db/connection'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/curtismn87/WDI/projects/myStox2/app/controllers/stocks.js:4:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
26 Aug 15:35:29 - [nodemon] app crashed - waiting for file changes before starting...
Can you push your code to GH and give me the link? I'll take a look.
You need ../../db/connection
.
It couldn't find the file, so it started looking for a module of that name.
Ahhhh works great! Thanks!
Once we add these two lines of code nodemon crashes and tell us in this line of code which is in our stocks controller
that "../db/connection" is not a module. Why does it think this path is now a module?