logo

Recording Node.js

For recording Node processes, Replay provides the @recordreplay/replay-node-cli npm package which can be used to execute and record a script.

Getting setup

bash
npm i @recordreplay/replay-node-cli --global replay-node script-name.js RECORD_REPLAY_API_KEY=YOUR-KEY npx @replayio/replay view-latest
Note: This will prompt you to install @replayio/replay if you haven’t already!

Example

Lets say you want to record loop.js
javascript
for (let i = 0; i < 5; i++) { console.log(`Hello ${i}`) }
You'd first create the replay with replay-node and then upload it with @replayio/replay:
bash
replay-node loop.js RECORD_REPLAY_API_KEY=YOUR-KEY replay-recordings view-latest
And once it's uploaded you'd be able to view it at app.replay.io:
Image without caption

TypeScript

If you want to record a ts-node invocation, invoke replay-node like so: replay-node --exec ts-node ...

Upgrading Node

Replay's fork of Node is in active development and it is recommended that you update it fairly regularly.
bash
replay-node --update

Was this page helpful?