{"id":15654745,"url":"https://github.com/ahmadnassri/node-pretty-exceptions","last_synced_at":"2025-08-20T18:32:35.513Z","repository":{"id":37086815,"uuid":"86897122","full_name":"ahmadnassri/node-pretty-exceptions","owner":"ahmadnassri","description":"Pretty and more helpful uncaught exceptions, automatically","archived":false,"fork":false,"pushed_at":"2024-06-17T20:01:41.000Z","size":1464,"stargazers_count":26,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-10T00:51:54.221Z","etag":null,"topics":["lib","node"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahmadnassri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["ahmadnassri"]}},"created_at":"2017-04-01T08:19:44.000Z","updated_at":"2024-06-17T20:01:44.000Z","dependencies_parsed_at":"2023-02-10T04:16:02.448Z","dependency_job_id":"35f6ad67-64ee-46c7-9073-d000140979f0","html_url":"https://github.com/ahmadnassri/node-pretty-exceptions","commit_stats":{"total_commits":374,"total_committers":3,"mean_commits":"124.66666666666667","dds":0.08823529411764708,"last_synced_commit":"d7a9e4370623f9cfe9a00a0ceafd1e0107ae34a6"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmadnassri%2Fnode-pretty-exceptions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmadnassri%2Fnode-pretty-exceptions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmadnassri%2Fnode-pretty-exceptions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmadnassri%2Fnode-pretty-exceptions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmadnassri","download_url":"https://codeload.github.com/ahmadnassri/node-pretty-exceptions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230445926,"owners_count":18227060,"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":["lib","node"],"created_at":"2024-10-03T12:53:53.705Z","updated_at":"2024-12-19T14:06:57.850Z","avatar_url":"https://github.com/ahmadnassri.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ahmadnassri"],"categories":[],"sub_categories":[],"readme":"# Pretty Exceptions\n\nPretty and more helpful uncaught exceptions, automatically.\n\n[![license][license-img]][license-url]\n[![release][release-img]][release-url]\n[![semantic][semantic-img]][semantic-url]\n\n![][1]\n\n## Usage\n\n### Library\n\n``` js\nconst pretty = require('pretty-exceptions/lib')\n\nconst options = {\n  source: true,\n  native: true,\n  color: true,\n  cwd: process.cwd()\n}\n\nconst output = pretty(new Error('foo'), options)\n```\n\n#### `options`\n\n| name       | type      | required | default         | description                              |\n|------------|-----------|----------|-----------------|------------------------------------------|\n| **source** | `Boolean` | ✖        | `false`         | Show source code in stack                |\n| **native** | `Boolean` | ✖        | `false`         | Show native code in stack                |\n| **color**  | `Boolean` | ✖        | `true`          | use ansi colors                          |\n| **cwd**    | `String`  | ✖        | `process.cwd()` | resolve file names relative to this path |\n\n### CLI *(preferred)*\n\nThis is the preferred approach to best avoid mistakingly including into production builds\n\n1.  setup your [`NODE_PATH`][] environment variable\n\n    ``` shell\n    export NODE_PATH=\"$NODE_PATH:$(npm root -g)\"\n    ```\n\n2.  install `pretty-exceptions`\n\n    ``` shell\n    npm install --global pretty-exceptions\n    ```\n\n3.  run your application with the [`--require`][] flag:\n\n    ``` shell\n    node --require pretty-exceptions my-app.js\n\n    # alternative modes (see below):\n    node --require pretty-exceptions/source my-app.js\n    ```\n\n#### Pro Tip:\n\nUse Bash Aliases for less typing\n\n``` shell\n# make a special alias for debugging\nalias node-ex='node --require pretty-exceptions'\n\n# or even better:\nalias node='node --require pretty-exceptions/source'\n```\n\n\u003e To make this persistent, you need to add this into your `~/.bashrc` *(or `~/.bash_profile`)*.\n\n#### Environment Variables\n\n| env                        | default | description               |\n|----------------------------|---------|---------------------------|\n| `PRETTY_EXCEPTIONS_SOURCE` | `0`     | Show source code in stack |\n| `PRETTY_EXCEPTIONS_NATIVE` | `0`     | Show native code in stack |\n| `PRETTY_EXCEPTIONS_COLOR`  | `1`     | use ansi colors           |\n\n### Source *(if you really must!)*\n\nRequire at the top-most entry point of your app:\n\n``` js\nrequire('pretty-exceptions')\n\n// alternative modes (see below):\nrequire('pretty-exceptions/source-native')\n```\n\n## Modes\n\n### Default\n\n``` shell\n$ node --require pretty-exceptions my-app.js\n```\n\n###### Output\n\n``` plain\nError: oh no! this is an error message!\n │\n └┬╼ /path/to/my-app.js\n  │\n  ├──╼ someOtherFunction @ line 2:27\n  ├──╼ someFunction @ line 6:3\n  └──╼ Object.\u003canonymous\u003e @ line 9:1\n```\n\n###### Demo\n\n\u003e Colors will vary based on your local terminal configuration\n\n![][2]\n\n### View Source\n\n``` shell\n$ node --require pretty-exceptions/source my-app.js\n# OR\n$ PRETTY_EXCEPTIONS_SOURCE=1 node --require pretty-exceptions my-app.js\n```\n\n###### Output\n\n``` plain\nError: oh no! this is an error message!\n │\n └┬╼ /path/to/my-app.js\n  │\n  ├──╼ someOtherFunction @ line 2\n  │\n  │    function someOtherFunction () {\n  ├╌╌╌╌╌╌╌╌╌╌╮\n  │    throw new Error('oh no! this is an error message!')\n  │    }\n  │\n  ├──╼ someFunction @ line 6\n  │\n  │    function someFunction () {\n  ├╌╌╌╌╮\n  │    someOtherFunction()\n  │    }\n  │\n  ├──╼ Object.\u003canonymous\u003e @ line 9\n  │\n  └╌╌╌╌╮\n       someFunction()\n```\n\n###### Demo\n\n\u003e Colors will vary based on your local terminal configuration\n\n![][3]\n\n### View Native Calls\n\n``` shell\n$ node --require pretty-exceptions/native my-app.js\n# OR\n$ PRETTY_EXCEPTIONS_NATIVE=true node --require pretty-exceptions my-app.js\n```\n\n###### Output\n\n``` plain\nError: oh no! this is an error message!\n │\n ├─┬╼ /path/to/my-app.js\n │ │\n │ ├──╼ someOtherFunction @ line 2:27\n │ ├──╼ someFunction @ line 6:3\n │ └──╼ Object.\u003canonymous\u003e @ line 9:1\n │\n ├─┬╼ module.js\n │ │\n │ ├──╼ Module._compile @ line 571:32\n │ ├──╼ Object.Module._extensions..js @ line 580:10\n │ ├──╼ Module.load @ line 488:32\n │ ├──╼ tryModuleLoad @ line 447:12\n │ ├──╼ Function.Module._load @ line 439:3\n │ └──╼ Module.runMain @ line 605:10\n │\n └┬╼ bootstrap_node.js\n  │\n  └──╼ run @ line 423:7\n```\n\n###### Demo\n\n\u003e Colors will vary based on your local terminal configuration\n\n![][4]\n\n### View Source \u0026 Native\n\n``` shell\n$ node --require pretty-exceptions/source-native my-app.js\n# OR\n$ PRETTY_EXCEPTIONS_SOURCE=1 PRETTY_EXCEPTIONS_NATIVE=1 node --require pretty-exceptions my-app.js\n```\n\n###### Output\n\n``` plain\nError: oh no! this is an error message!\n │\n ├─┬╼ /path/to/my-app.js\n │ │\n │ ├──╼ someOtherFunction @ line 2\n │ │\n │ │    function someOtherFunction () {\n │ ├╌╌╌╌╌╌╌╌╌╌╮\n │ │    throw new Error('oh no! this is an error message!')\n │ │    }\n │ │\n │ ├──╼ someFunction @ line 6\n │ │\n │ │    function someFunction () {\n │ ├╌╌╌╌╮\n │ │    someOtherFunction()\n │ │    }\n │ │\n │ ├──╼ Object.\u003canonymous\u003e @ line 9\n │ │\n │ └╌╌╌╌╮\n │      someFunction()\n │ \n │\n ├─┬╼ module.js\n │ │\n │ ├──╼ Module._compile @ line 571\n │ ├──╼ Object.Module._extensions..js @ line 580\n │ ├──╼ Module.load @ line 488\n │ ├──╼ tryModuleLoad @ line 447\n │ ├──╼ Function.Module._load @ line 439\n │ └──╼ Module.runMain @ line 605\n │\n └┬╼ bootstrap_node.js\n  │\n  └──╼ run @ line 423\n```\n\n###### Demo\n\n\u003e Colors will vary based on your local terminal configuration\n\n![][5]\n\n  [1]: ./screenshots/example.png\n  [`NODE_PATH`]: https://nodejs.org/docs/latest/api/modules.html#modules_loading_from_the_global_folders\n  [`--require`]: https://nodejs.org/api/cli.html#cli_r_require_module\n  [2]: ./screenshots/default.png\n  [3]: ./screenshots/source.png\n  [4]: ./screenshots/native.png\n  [5]: ./screenshots/source-native.png\n\n----\n\u003e Author: [Ahmad Nassri](https://www.ahmadnassri.com/) \u0026bull;\n\u003e Twitter: [@AhmadNassri](https://twitter.com/AhmadNassri)\n\n[license-url]: LICENSE\n[license-img]: https://badgen.net/github/license/ahmadnassri/node-pretty-exceptions\n\n[release-url]: https://github.com/ahmadnassri/node-pretty-exceptions/releases\n[release-img]: https://badgen.net/github/release/ahmadnassri/node-pretty-exceptions\n\n[semantic-url]: https://github.com/ahmadnassri/node-pretty-exceptions/actions?query=workflow%3Arelease\n[semantic-img]: https://badgen.net/badge/📦/semantically%20released/blue\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmadnassri%2Fnode-pretty-exceptions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmadnassri%2Fnode-pretty-exceptions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmadnassri%2Fnode-pretty-exceptions/lists"}