Using NPM Packages in Nova Extensions

Although the Nova extension JavaScript runtime is not an instance of the Node.js runtime, we can use popular module bundlers to import some existing NPM packages when creating a Nova extension.

NPM packages that depend on Node.js built-ins — fs, https, path, etc. — are incompatible with Nova’s runtime, even when using a module bundler.

APIs & Executables

Many NPM packages expose functionality through APIs, CLI executables (used on the command line), or both. This guide covers how to use module bundlers to import APIs exposed by packages hosted on NPM.

Based on your needs or the API dependencies of the package you’re using, however, it may be preferable to use the executable instead.

For example, even though we can’t import the jsonlint API into a Nova extension, due in part to its use of the file and fs built-ins, the jsonlint CLI included in the package can be invoked by Nova’s Process class.

If you find yourself wanting to invoke an NPM package’s executable in your Nova extension, you might consider using nova-npm-executable to help manage those dependencies.

Let’s get started!

Part 2: Structuring Your Project

This article was last updated on July 27, 2020