diff --git a/README.md b/README.md index 404a668..599842f 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ on a best-efforts basis: - Java (see caveats) - C# (c-sharp) using dotnet core - Go (requires separate installation of [Delve][]) +- Node.js (requires node <12 for installation) ## Languages known not to work @@ -160,6 +161,7 @@ The debug adapters themselves have certain runtime dependencies: | C# (dotnet core) | Experimental | `--force-enable-csharp` | netcoredbg | DotNet core | | C# (mono) | Experimental | `--force-enable-csharp` | vscode-mono-debug | Mono | | Go | Experimental | `--enable-go` | vscode-go | Go, [Delve][] | +| Node.js | Experimental | `--force-enable-node` | vscode-node-debug2 | 6 < Node < 12, Npm | For other languages, you'll need some other way to install the gadget. @@ -605,6 +607,36 @@ Requires: } ``` +* Node.js + +Requires: + +* `install_gadget.py --force-enable-node` +* For installation, a Node.js environemt that is < node 12. I believe this is an + incompatibility with gulp. Advice, use [nvm][] with `nvm install --lts 10; nvm + use --lts 10; ./install_gadget.py --force-enable-node ...` + +* Options described here: + https://code.visualstudio.com/docs/nodejs/nodejs-debugging + +```json +{ + "configurations": { + "run": { + "adapter": "vscode-node", + "configuration": { + "request": "launch", + "protocol": "auto", + "stopOnEntry": true, + "console": "integratedTerminal", + "program": "${workspaceRoot}/simple.js", + "cwd": "${workspaceRoot}" + } + } + } +} +``` + Also the mock debugger, but that isn't actually useful. ## Partially supported diff --git a/install_gadget.py b/install_gadget.py index 627a47a..1e47501 100755 --- a/install_gadget.py +++ b/install_gadget.py @@ -206,6 +206,25 @@ GADGETS = { }, }, }, + 'vscode-node-debug2': { + 'language': 'node', + 'enabled': False, + 'repo': { + 'url': 'https://github.com/microsoft/vscode-node-debug2', + 'ref': 'v1.39.1', + }, + 'do': lambda name, root: InstallNodeDebug( name, root ), + 'adapters': { + 'vscode-node': { + 'name': 'node2', + 'type': 'node2', + 'command': [ + 'node', + '${gadgetDir}/vscode-node-debug2/out/src/nodeDebug.js' + ] + }, + }, + }, } @@ -279,6 +298,26 @@ def InstallTclProDebug( name, root ): MakeSymlink( gadget_dir, name, root ) +def InstallNodeDebug( name, root ): + node_version = subprocess.check_output( [ 'node', '--version' ] ).strip() + print( "Node.js version: {}".format( node_version ) ) + if map( int, node_version[ 1: ].split( '.' ) ) >= [ 12, 0, 0 ]: + print( "Can't install vscode-debug-node2:" ) + print( "Sorry, you appear to be running node 12 or later. That's not " + "compatible with the build system for this extension, and as far as " + "we know, there isn't a pre-built independent package." ) + print( "My advice is to install nvm, then do:" ) + print( " $ nvm install --lts 10" ) + print( " $ nvm use --lts 10" ) + print( " $ ./install_gadget.py --enable-node ..." ) + raise RuntimeError( 'Invalid node environent for node debugger' ) + + with CurrentWorkingDir( root ): + subprocess.check_call( [ 'npm', 'install' ] ) + subprocess.check_call( [ 'npm', 'run', 'build' ] ) + MakeSymlink( gadget_dir, name, root ) + + def DownloadFileTo( url, destination, file_name = None, checksum = None ): if not file_name: file_name = url.split( '/' )[ -1 ] @@ -396,6 +435,12 @@ def CloneRepoTo( url, ref, destination ): RemoveIfExists( destination ) subprocess.check_call( [ 'git', 'clone', url, destination ] ) subprocess.check_call( [ 'git', '-C', destination, 'checkout', ref ] ) + subprocess.check_call( [ 'git', 'submodule', 'sync', '--recursive' ] ) + subprocess.check_call( [ 'git', + 'submodule', + 'update', + '--init', + '--recursive' ] ) OS = install.GetOS() diff --git a/support/test/node/simple/.tern-project b/support/test/node/simple/.tern-project new file mode 100644 index 0000000..f71dc86 --- /dev/null +++ b/support/test/node/simple/.tern-project @@ -0,0 +1,5 @@ +{ + "plugins": { + "node": {} + } +} diff --git a/support/test/node/simple/.vimspector.json b/support/test/node/simple/.vimspector.json new file mode 100644 index 0000000..c61fc3d --- /dev/null +++ b/support/test/node/simple/.vimspector.json @@ -0,0 +1,15 @@ +{ + "configurations": { + "run": { + "adapter": "vscode-node", + "configuration": { + "request": "launch", + "protocol": "auto", + "stopOnEntry": true, + "console": "integratedTerminal", + "program": "${workspaceRoot}/simple.js", + "cwd": "${workspaceRoot}" + } + } + } +} diff --git a/support/test/node/simple/simple.js b/support/test/node/simple/simple.js new file mode 100644 index 0000000..fc6e558 --- /dev/null +++ b/support/test/node/simple/simple.js @@ -0,0 +1,3 @@ +var msg = 'Hello, world!' + +console.log( "OK stuff happened" )