samedi 28 juillet 2018

Why Mocha.js can't find the module ?

I can't figure out why mocha.js can't find my path ! Here's the file structure that I included in my project for the node course

  ///////Root
  --package.json
  --node_modules/
  --playground
  --server
     -server.js
     -db
     -models
     -tests
           ---server.test.js

Every time I run "mocha server/**/*.test.js" I get this error from the command prompt after running the test command from the command prompt :

    > todo-api@1.0.0 test C:\Users\Omar Ali\Desktop\node-todo-api
> mocha server/**/*.test.js

module.js:549
    throw err;
    ^

Error: Cannot find module '../server/server'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\Omar Ali\Desktop\node-todo-api\server\tests\
server.test.js:6:9)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at C:\Users\Omar Ali\Desktop\node-todo-api\node_modules\mocha\lib\mocha.js:2
50:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (C:\Users\Omar Ali\Desktop\node-todo-api\node_modules\moc
ha\lib\mocha.js:247:14)
    at Mocha.run (C:\Users\Omar Ali\Desktop\node-todo-api\node_modules\mocha\lib
\mocha.js:576:10)
    at Object.<anonymous> (C:\Users\Omar Ali\Desktop\node-todo-api\node_modules\
mocha\bin\_mocha:637:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todo-api@1.0.0 test: `mocha server/**/*.test.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todo-api@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Omar Ali\AppData\Roaming\npm-cache\_logs\2018-07-28T18_00_
44_790Z-debug.log

Aucun commentaire:

Enregistrer un commentaire