简体   繁体   中英

Can't find mongoose module NodeJS require

for some reason I can't get my require to work, it should just find both models fine but the path for the file just won't work.

  • app
    • models
      • user.js
      • match.js
  • server.js

Seems like a simple fix but cannot seem to do it myself right now. I'm using (var User = require('/app/models/user.js');)

Thanks guys.

Actually you also can write it as,

var User = require('./app/models/user')

without even putting .js at the end, as it is added by default.. Just a tip to know :)

and here ./ means the current directory.

Hope it helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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