Esm: How to utilize esm to run scripts

Created on 26 Nov 2018  路  3Comments  路  Source: standard-things/esm

In the past days I've looked into ways to setup a project, where I just want to run individual scripts using ES6 module syntax. The environment would be vscode and it's code-runner extension to run a file at my discretion, so nodemon is not required.

While esm looks great, I'm under the impression that it promotes a project design where there is only one entry point, which is good if your creating a node app. What I'm looking at instead, is just having a project with a src directory containing sub-directories for different types of single file experiments that also use ES6 module syntax.

How do I use esm in this context and for this purpose?

question

Most helpful comment

Thank-you for esm, here how it works in vscode code-runner :)

"code-runner.executorMap": { "javascript": "node -r esm $fullFileName" }

All 3 comments

Hi @MVSICA-FICTA!

You can use esm as an application or package loader. As an application loader you can execute scripts by way of

node -r esm ./path/to/script

assuming esm is resolvable _(as any other node_modules is)_ of the path you're in.

Thank-you for esm, here how it works in vscode code-runner :)

"code-runner.executorMap": { "javascript": "node -r esm $fullFileName" }

Thanks for the update @MVSICA-FICTA!

The code-runner VS Code extension looks neat!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dnalborczyk picture dnalborczyk  路  3Comments

bensampaio picture bensampaio  路  3Comments

greggb picture greggb  路  3Comments

mAAdhaTTah picture mAAdhaTTah  路  3Comments

StphamZ picture StphamZ  路  3Comments