I am trying to use iron-node (v2.2.17) to debug my mocha unit-tests. The unit-tests run fine when I run this command from my package.json:
"test": "cross-env NODE_ENV=test mocha test/.setup.js --reporter progress --compilers js:babel-core/register --require babel-polyfill --recursive \"./src/**/*.spec.js\" \"./src/**/*.integrationSpec.js\" \"./test/**/*.spec.js\"",
However when I run this command the tests fail:
"debug:test": "cross-env NODE_ENV=test iron-node node_modules\\mocha\\bin\\_mocha test/.setup.js --reporter progress --compilers js:babel-core/register --require babel-polyfill --recursive \"./src/**/*.spec.js\" \"./src/**/*.integrationSpec.js\" \"./test/**/*.spec.js\"",
The error in the console is:
Error: Cannot find module 'src/framework/api/entityAddresses/entityAddressesAc tions'
- module.js:16 require
internal/module.js:16:19
- entityAddressesActions.spec.js:5 Object.<anonymous>
entityAddressesActions.spec.js:5:1
This module is located in C:\TFS\Dev-UI\WebApp\Src\Web\Web\src\framework\api\entityAddresses\entityAddressesActions.js
My project folder is C:\TFS\Dev-UI\WebApp\Src\Web\Web
and my process.env.NODE_PATH
is also C:\TFS\Dev-UI\WebApp\Src\Web\Web
. (it was undefined but I set it to process.cwd()
in my .iron-node.js
- see https://github.com/s-a/iron-node/issues/98#issuecomment-218658236)
I can't figure out why the module is not found. Am I missing some configuration?
edit
This SO answer suggests setting process.env.NODE_PATH
once the app has started won't work because the module paths are cached: Determine project root from a running node.js application
I am at a loss as to how to set this before iron-node starts, it is always undefined