Friday, 28 April 2017

Error: Cannot find module 'C:\server.js' in Node server for Meanjs

I have git cloned meanjs into a folder in D: drive as shown below and ran the command npm start to start the node server.

admin@admin-PC MINGW32 /d/Udemy Angular 1 projects/Project5/jobfinder (master)
$ npm start

> meanjs@0.5.0 start D:\Udemy Angular 1 projects\Project5\jobfinder
> gulp

[23:41:30] Using gulpfile D:\Udemy Angular 1 projects\Project5\jobfinder\gulpfile.js

....and got the below error.

Error: Cannot find module 'C:\server.js'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
[23:58:35] [nodemon] app crashed - waiting for file changes before starting...

After that, just to give it a try I copied the server.js from the current directory to C:/ and issued 'npm start' command at git bash from the same directory and the error changed to below.

Debugger listening on [::]:5858
module.js:457
throw err;
^

Error: Cannot find module './config/lib/app'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\server.js:6:11)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
[23:41:52] [nodemon] app crashed - waiting for file changes before starting...

Can anyone please help me understand why is Node looking for server.js and other resources at C:/ instead of the current directory? Is there anything very simple I am missing out (though I find it quite strange !). Btw sorry for posting the git bash errors as code since I did not have enough reputations to post more than one image link.

Cheers!



via Abinash Gupta

No comments:

Post a Comment