Cannot find module 'ts-node/register'

前端 未结 7 1678
青春惊慌失措
青春惊慌失措 2021-02-06 20:01

I want to use mocha to test my TypeScript/Angular2 project. I tried to use ts-node as described here:

npm install -g ts-node
<
7条回答
  •  执念已碎
    2021-02-06 21:02

    Wow, a silly mistake can cost you time. I was facing the same issue when I was trying to debug my nodejs application. The mistake I had done was that I have created my .vscode folder outside of my nodejs app folder(the directory which had node_modules in it). When I moved my .vscode to that folder, everything work fine. Below is my launch.json file.

    {
        "version": "0.2.0",
        "configurations": [
            {
                "type": "node",
                "request": "launch",
                "name": "index",         
                "args": [
                    "src/index.ts"
                ],
                "runtimeArgs": [
                    "-r",
                    "ts-node/register"
                ],
                "cwd": "${workspaceFolder}",
                "protocol": "inspector",
                "internalConsoleOptions": "openOnSessionStart"           
            }
        ],
        "compounds": []
    }
    

提交回复
热议问题