question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Debugging and npm scripts

See original GitHub issue

I’m looking for a way to run some npm scripts in Visual Studio Code (to lint/build/etc), then run, say, jasmine in debug mode from VSCode.

Currently to debug my tests, I have to:

npm run build_stuff
jasmine

I’d like to run the npm run build_stuff out of debug mode, then debug jasmine, which is running specs in my project.

Is it the intent of this extension to help support that use case?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
egammacommented, Feb 1, 2016

How about you leave your build process as is, but once a test fails then you run tests under the debugger. To do so you can define a launch configuration as follows:

  • Press F5 or the debug icon
  • select node from the quick box
  • edit the launch.json as follows (this assumes that jasmine is installed locally).
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "jasmine",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/node_modules/jasmine/bin/jasmine.js",
            "stopOnEntry": false,
            "args": [],
            "cwd": "${workspaceRoot}",
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development"
            }
        }
    ]
}

If you always want to run the tests under the debugger then you could do what is described in this blog for debugging mocha tests, that is, you launch the tests and attach the debugger.

0reactions
fabian-devcommented, Apr 7, 2016

The configuration Erich suggested works fine for me. Thanks!

I do as well debug other gulp tasks this way by adding new launch.js configurations this way: "program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js" "args": [ "jasmine" ]

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the proper way to debug an npm script using vscode?
1. Possible duplicate of How to debug using npm run scripts from VSCode? – Jakub Synowiec · Agreed at duplicate, and I recommend...
Read more >
Debug Node.js Apps using Visual Studio Code
The Visual Studio Code editor includes Node.js debugging support. Set breakpoints, step-in, inspect variables and more.
Read more >
Cannot run npm scripts for debugging. · Issue #152613 - GitHub
Issue Type: Bug Open a node.js project in the NPM script bar in the explorer, click the debug button Result: Instead of starting...
Read more >
Prompt to "Terminate Batch Job" when debugging NPM scripts ...
Prompt to "Terminate Batch Job" when debugging NPM scripts if using NPM binary as a package manager. When stop "run" command Webstrom now...
Read more >
How to Debug Node.js Code Using Multiple Tools - Kinsta
Use Node.js Command Line Options · --check syntax check the script without executing · --trace-warnings output a stack trace when JavaScript ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found