Search code examples
node.jsmean-stacknode-modulesgit-bashnodemon

Node/Git Bash, distorted file path when starting server. Bug or user error?


I'm following along with an example mean stack project. Node/nodemon is experiencing issues in git bash where it produces a throw error when I try to start the server.

    Error: Cannot find module 'C:\Users\Emma\desktop\trainingapprc\app.js'

The main directory is called trainingapp, and below it should be src\app.js. Nodemon is leaving out a "\s" between the root directory and src, causing the error. When I run the server with just node, it forgets the src folder completely:

    Error: Cannot find module 'C:\Users\Emma\desktop\trainingapp\app.js'

I pulled the example project from github and it does not have this error, even though the directory tree is exactly the same except for the directory name.

I'm new to coding so I'm not sure how to proceed. Is this a bug or user error?


Solution

  • 1.Comment out Lines In app.js:

    var router = require('./api');   
    app.use('/api', router);
    

    2.place a . in the code ../public :

    app.use('/', express.static('../public'));