Sunday 13 December 2020

Using NODE_PATH in vscode debugger

I want to auto-restart my nodeJs debugger, so I have to use Nodemon for that.

My package.json scripts:

"scripts": {
    "dev": "NODE_PATH=src env-cmd -f ./src/config/env/development.env nodemon ./src/app.js",
    "test": "NODE_PATH=src env-cmd -f ./src/config/env/test.env jest"
}

and here's launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/src/app.js",
            "restart": true,
            "runtimeExecutable": "nodemon"
        }
    ]
}

now after running the debugger I got the following error:

Uncaught Error: Cannot find module 'config/cache'

I guess I should tell the launch.json configuration to use NODE_PATH=src as I did in the package.json file. I'm not sure if it's the case.



from Using NODE_PATH in vscode debugger

No comments:

Post a Comment