{"id":22202158,"url":"https://github.com/rumkin/npx-esm","last_synced_at":"2025-03-25T00:59:33.526Z","repository":{"id":143901933,"uuid":"271397293","full_name":"rumkin/npx-esm","owner":"rumkin","description":"Run ESM programs with Node.js’ NPX util","archived":false,"fork":false,"pushed_at":"2020-07-05T08:06:58.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T10:48:33.665Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rumkin.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-10T22:19:14.000Z","updated_at":"2020-07-05T08:07:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e3c55e3-7504-47e7-8caf-9ad9af78e162","html_url":"https://github.com/rumkin/npx-esm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fnpx-esm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fnpx-esm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fnpx-esm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Fnpx-esm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rumkin","download_url":"https://codeload.github.com/rumkin/npx-esm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245377989,"owners_count":20605377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T16:12:35.176Z","updated_at":"2025-03-25T00:59:33.513Z","avatar_url":"https://github.com/rumkin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NPX ESM\n\nRun ESM modules as node programs with npx in a three steps.\n\n1. Install `npx-esm` package:\n  ```shell\n  npm install -D npx-esm\n  ```\n2. Create program `index.js`:\n  ```js\n  export default function() {\n    console.log('Hello')\n  }\n  ```\n3. Execute it:\n  ```shell\n  npx esm index.js\n  ```\n\n## API\n\n### `CmdParams`\n```text\n{\n  argv: Array\u003cstring\u003e,\n  argvHead: Array\u003cstring\u003e,\n  cwd: string,\n  stdin: ReadableStream,\n  stdout: WritableStream,\n  stderr: WriteableStream,\n}\n```\n\nThe main function receives a command params as the first argument. It contains minimal set of params to execute a command and interact with the user or pipeline.\n\n* `argv` is the list of command line arguments remained after removing executable adn script paths.\n* `argvHead` is the list of command line arguments cropped as executable and script paths.\n* `cwd` is the current directory.\n* `stdin`, `stdout` and `stderr` are I/O streams.\n\n#### Example\n```js\nasync function main({\n  argv, // -\u003e ['--help']\n  argvHead, // -\u003e ['node', 'script.js']\n  cwd, // '/dev/project/esm'\n  stdout, // writable stream\n  stderr, // writable stream\n  stdin, // readable stream\n}) {\n  stdout.write('OK')\n  return 1\n}\n```\n\n## License\n\nMIT © [Rumkin](https://rumk.in)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Fnpx-esm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frumkin%2Fnpx-esm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Fnpx-esm/lists"}