DEV Community

allnulled
allnulled

Posted on

Node.js code injection with nodelive

This is a small tutorial on how to debug your any Node.js program from your preferred editor.

You will be able to open a Node.js 'shell' to stop your program at some point of the code.

First, install nodelive:

$ npm i -s nodelive

Second, import the package:

const nodelive = require("nodelive")

Finally, open the editor:

await nodelive.editor({
  custom: "vars"
})

And boom!!! You are inside.

To output things by console, you con log them or return them.

You can use await directly, no need to wrap the code in the editor, which is very handy.

To get out and continue your program, just save the file automatically opened, empty.

And three more notes.

  • The await keyword will make the debugging blockant.
  • It will try to open Sublime Text by default. To configure this, set the variable:
nodelive.PREFERRED_EDITOR = 'brackets'

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay