JS Modules

JavaScript files can be imported directly in your Clio code. For Both cjs and esm are supported, for cjs you can do:

module.exports.hello = function(name) {
    console.log(`Hello ${name}`);
}

and to import it in Clio:

And for esm, you can do:

export const hello = function(name) {
    console.log(`Hello ${name}`);
}

and to import it in Clio:

When importing JavaScript files it’s better to include .js in the file name. Same as Clio modules, these imports are relative and recognise the same path formats as the Clio file imports.

To import and use a Node.js module, install it using clio deps add --npm

clio deps add --npm express

Then you can import it in your Clio file:

Both esm and cjs modules are supported.