1

I am using npm start script like this

"start": "cross-env NODE_PATH=. nodemon index.js"

and now I want to debug app with nodemon and my launch.json file configuration is like this

    "type": "node",
            "request": "launch",
            "name": "nodemon",
            "runtimeExecutable": "nodemon",
            "program": "${workspaceFolder}/node-api-boilerplate/index.js",
            "restart": true,
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen"
        }

now I unable to understand that how to execute cross-env command. Please help me.

error is something like this

Cannot find module 'src/container'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (E:\nodeProject\sailway education\node-api-boilerplate\index.js:1:81)
    at Module._compile (internal/modules/cjs/loader.js:685:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
Waiting for the debugger to disconnect...
1
  • your launch.json will simply run runtimeExecutable+program: nodemon ${workspaceFolder}/node-api-boilerplate/index.js, so cross-env wont be even called in Commented Jan 27, 2020 at 16:37

1 Answer 1

2

[Old question, but I've just encountered a similar case myself]

You can drop cross-env, and just use VS Code's env object. So your provided launch.json becomes:

{
  "type": "node",
  "request": "launch",
  "name": "nodemon",
  "runtimeExecutable": "nodemon",
  "program": "${workspaceFolder}/node-api-boilerplate/index.js",
  "restart": true,
  "console": "integratedTerminal",
  "internalConsoleOptions": "neverOpen",
  "env": { "NODE_PATH": "." }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.