2017-11-25 6 views
-2
module.js:471 
    throw err; 
    ^

Error: Cannot find module '..models/article' 
    at Function.Module._resolveFilename (module.js:469:15) 
    at Function.Module._load (module.js:417:25) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (C:\Users\Sankalp Singhai\blogapp\server\routes\api.js 
:4:17) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (C:\Users\Sankalp Singhai\blogapp\server.js:7:13) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 

모듈 폴더를 어디에서 찾을 수 있습니까? 데이터베이스 연결 오류입니다. mlab에 데이터베이스를 만들었습니다.무엇이 잘못되었는지 알 수 없습니다. 디버그 방법

답변

-1
C:\Users\Sankalp Singhai\blogapp>node server.js 
(node:4068) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, us 
e `openUri()` instead, or set the `useMongoClient` option if using `connect()` o 
r `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mong 
o-client 
Running on localhost: ${port} 
Error connecting 
(node:4068) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejec 
tion id: 1): MongoError: failed to connect to server [6:27017] on first connect 
[MongoError: getaddrinfo ENOTFOUND 6 6:27017] 

오류 템플릿 문자열을 사용하려면

+0

를 연결, 당신은 백 틱 "'"를 사용합니다. 그것없이'$ {port} '를 사용하고있는 것처럼 보입니다. 또한 이의 제기를 삼가하십시오. 원하는 경우 새 발행물을 시작하거나 주석으로 게시 할 수 있습니다. 실제로 코드를보기 전에이 문제를 디버깅 할 수 없습니다. – weirdpanda

+0

코드를 첨부했습니다. –

+0

Mongo 인스턴스가 실행 중입니까? 그렇다면 구성은 어디에 있습니까? 어떻게 데이터베이스에 연결하고 있습니까? 'MongoError' 라인은'server.js' 파일과 아무 관련이 없다고 말해야합니다; Mongo 구성을 확인하십시오. 또한 '로컬 호스트에서 실행 : $ {포트}'를'\'로컬 호스트에서 실행 : $ {포트} \'' – weirdpanda

0
const express = require('express'); 
    const bodyParser = require('body-parser'); 
    const path = require('path'); 
    const http = require('http'); 
    const app = express(); 

    const api = require('./server/routes/api'); 
    //parsers 
    app.use(bodyParser.json()); 
    app.use(bodyParser.urlencoded({extended : false})); 

    app.use(express.static(path.join(__dirname,'dist'))); 

    app.use('/api' , api) 

    app.get('*', (req,res)=>{ 
     res.sendFile(path.join(__dirname, 'dist/index.html')); 
    }); 

    //set port 
    const port = process.env.PORT || '3000'; 
    app.set('port' , port); 

    const server = http.createServer(app); 

    server.listen(port,() => console.log('Running on localhost: ${port}')); 

**server.js**