如何执行交叉命令与代码调试器



我正在使用npm开始脚本

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

现在,我想使用nodemon和我的启动。

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

现在,我无法理解如何执行交叉ENV命令。请帮助我。

错误是这样的

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:nodeProjectsailway educationnode-api-boilerplateindex.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...

[旧问题,但我刚刚遇到了一个类似的情况]

您可以删除cross-env,只需使用VS代码的env对象即可。因此您提供的launch.json变为:

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

相关内容

  • 没有找到相关文章

最新更新