Downloading VS Code Insider build and Node-ChakraCore
To try it out you first need to install the Visual Studio Code Insider build.
The readme suggests using Node Version Switcher to install Node-ChakraCore. But, if you would rather not risk having yet another Node version manager mess up your system, I would recommend directly downloading the prebuilt binaries.
I had some issues with the latest release, but those are fixed in the nightly build. Just select the most recent build based on the date.
Once there’s a newer version than 7.0.0-pre10 on the releases page you can also download it there.
After downloading Node-ChakraCore, unzip the file, find the
node executable in the bin folder, and copy the path to it.
test.js file with the following content:
Record replay data
Then, in the terminal, run
test.js with the downloaded Node-ChakraCore build. To be able to time travel later you need to install recording using the
Run this in the directory that contains
/Users/mattDownloads/node-v7.0.0-nightly2016...-darwin-x64/bin/node -TTRecord:log test.js
(The exact path will depend on where you downloaded the
node executable to.)
This will create a log directory containing the time travel data recorded by Node-ChakraCore.
Configure the VS Code project
In the VS Code sidebar select the debugger. Click the “Start Debugging” button to start configuring the project.
In the dropdown just select Node.js for now.
We need to make a few manual changes to the
launch.json file that was just created.
First, change the
program property to
Then add a
runtimeExecutable property that contains the location of the downloaded Node-ChakraCore binary.
Finally, add a
runtimeArgs property with the value
"runtimeExecutable": "/Users/.../node-nightly.../bin/node", "runtimeArgs": ["-TTDebug:log", "-TTBreakFirst"]
Your launch.json file will look something like this:
Now click the “Start Debugging” button again and VS Code will pause at the debugger statement in test.js.
Right now the value of
a is 11. Use the “Step Back” button in the stepping controls and see how the value in the Variables pane is updated to the previous value.
Trying your own code
You can change the content of
test.js as you like, but you’ll have to update the recording in the terminal before debugging in VS Code.
When debugging in VS Code you won’t be able to see output generated by
However, you can instead use the
Note that unlike
console.log, the first parameter to
telemetryLog has to be a string. The second parameter (
printFlag) indicates whether the log should appear in the console during the replay.
For more info, take a look at the time-travel debugging readme in the Node-ChakraCore repo.