9

So, I'm playing around with this new framework http://nestjs.com/ who seems pretty awesome since it allows the usage of Typescript on Node, very likely to angular.

Using the starter https://github.com/kamilmysliwiec/nest-typescript-starter, I can run it with npm run start without any problem, but since there is a .vscode on the project, I assumed I could use VS Code to run and gain some debug abilities.

The problem is that when I run directly from VS Code, without changing anything in the code, I get the following problem:

Error: Cannot find module 'nest.js'

I tried to run from VS Code with and without it running from NPM, no success.

Thanks in advance.

1
  • 1
    Apparently changing the launch.json to be "program": "${workspaceRoot}\\index.js" instead of "program": "${workspaceRoot}\\src\\server.ts" and removing outFiles did the job. I will leave it here to see if it's correct. Commented May 19, 2017 at 20:26

3 Answers 3

10

I updated nest-typescript-starter today. The previous version had an old dist directory, with outdated imported packages. If you want to compile your application, use npm run start:prod script.

Sign up to request clarification or add additional context in comments.

Comments

4

To debug with nestjs app. In 2020, after I follow first-step. In VS code change default setting from:

"version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "program": "${workspaceFolder}/start",
      "preLaunchTask": "tsc: build - tsconfig.json",
      "outFiles": [
        "${workspaceFolder}/dist/**/*.js"
      ]
    }
  ]

to this:

"version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": ["<node_internals>/**"],
      "program": "${workspaceFolder}/src/main.ts",
      "preLaunchTask": "tsc: build - tsconfig.json",
      "outFiles": ["${workspaceFolder}/dist/**/*.js"]
    }
  ]

And press F5 to debug. It works perfectly with me.

Comments

0

For those looking for a launch.json. There is one described at https://github.com/nestjs/nest/issues/776

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}\\src\\main.ts",
            "preLaunchTask": "tsc: build - tsconfig.json",
            "outFiles": [
                "${workspaceFolder}/dist/**/*.js"
            ]
        }
    ]
}

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.