{"name":"parent-module","version":"3.0.0","description":"Get the path of the parent module","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/parent-module.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["parent","module","package","caller","calling","module","path","callsites","callsite","stacktrace","stack","trace","function","file"],"dependencies":{"callsites":"^4.0.0"},"devDependencies":{"ava":"^3.15.0","execa":"^5.1.1","tsd":"^0.17.0","xo":"^0.45.0"},"gitHead":"e99192a8f6870dde49947643c7324a3797515de6","bugs":{"url":"https://github.com/sindresorhus/parent-module/issues"},"homepage":"https://github.com/sindresorhus/parent-module#readme","_id":"parent-module@3.0.0","_nodeVersion":"12.22.1","_npmVersion":"7.20.3","dist":{"integrity":"sha512-zJXn5iKdXXUV51iC7O4nHiPs/eWnkd0obrHDlOKQ6/MafFrxljinW6hCkr0UTsAGq7B+NXT2wIfLshcD+5RvIw==","shasum":"4bddc5cc0584935189977bae3384cc66dedde363","tarball":"http://registry-npm.ywwl.com/parent-module/download/parent-module-3.0.0.tgz","fileCount":5,"unpackedSize":4939,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh22RrCRA9TVsSAnZWagAA0jcP/AlCpLLxFecwaCI5BD9p\nGVJ5tSYVZyEKyt++9zZmYZ9NkpOAzdjwpwofWXPto+C++msR5ZQPJLFmHuXm\nvqJT39rsizQkMW3lnSS3svWKHAk/MLkxtOOAEV2rVqNDBMcIgLqNR5/BjB3j\nEtf57OkNM0Gat7KsJWlWSe8jghktZo+fHeSB8+4p9H2i+ITkOGtv6K9janTK\n/XaZ4RWEFyxPZsWc6EUEZxDKKL0Oy52WglfGg6bnhdpiBfhhUC6BepUmpZDO\nOsk0uzUi44e0oSci8lYW5IP3R4gRZW0JLsLWu8t8dQmQ0SaMxzp8PlLGZja9\nmz+bdHhLJgsjb4RucIe0CMWWAm1g2Nz3QgAOkXf+0vW4TqoJmI9ikyaroYTM\nRsBqg2yv/vIXbv354htHnOwJyJrvJDiB5cF058pqT59PLnbhsHQm8Mu+l4BI\nxRGaJsLSHuT7gjdc8jkge//v/Oy/jXr3fvVMpcuVrARAhuG0hwVkOkoDu8ZP\n/N372RqZhxCwpQiySAXZhm+IpD97hZngGYXbJWIgCGUHVWjU787YO5aHQGGL\nGJUpFkD5kg7CKHI2IeXzqsjECPQcZxBul448b8ioqeNCyiBIIUvrqbZfo8KS\nxe2V15wOf3KpZ+4NyipBoM0xpPj6YoP+zvZmi+DHLI4cuF9sZ6WRPyui4aM7\nw0MW\r\n=WtnO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC/Fj9QO37vURVKlLGmOKOuJUaPovPItL/wAywaz1RxBAiAWrnwe9itWtPuCZQkeCTYME3fh5C/vG6jjKX2dE/y4Sw=="}],"size":2346,"noattachment":false,"key":"/parent-module/-/parent-module-3.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/parent-module_3.0.0_1633335216602_0.5745603950022955"},"_hasShrinkwrap":false,"readme":"# parent-module\n\n> Get the path of the parent module\n\nNode.js exposes `module.parent`, but it only gives you the first cached parent, which is not necessarily the actual parent.\n\n## Install\n\n```sh\nnpm install parent-module\n```\n\n## Usage\n\n```js\n// bar.js\nimport parentModule from 'parent-module';\n\nexport default function bar() {\n\tconsole.log(parentModule());\n\t//=> '/Users/sindresorhus/dev/unicorn/foo.js'\n};\n```\n\n```js\n// foo.js\nimport bar from './bar.js';\n\nbar();\n```\n\n## API\n\n### parentModule(filePath?)\n\nBy default, it will return the path of the immediate parent.\n\n#### filePath\n\nType: `string`\\\nDefault: [`__filename`](https://nodejs.org/api/globals.html#globals_filename)\n\nThe file path of the module of which to get the parent path.\n\nUseful if you want it to work [multiple module levels down](fixtures/filepath).\n\n## Tip\n\nCombine it with [`read-pkg-up`](https://github.com/sindresorhus/read-pkg-up) to read the package.json of the parent module.\n\n```js\nimport path from 'node:path';\nimport {readPackageUpSync} from 'read-pkg-up';\nimport parentModule from 'parent-module';\n\nconsole.log(readPackageUpSync({cwd: path.dirname(parentModule())}).pkg);\n//=> {name: 'chalk', version: '1.0.0', …}\n```\n\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<a href=\"https://tidelift.com/subscription/pkg/npm-parent-module?utm_source=npm-parent-module&utm_medium=referral&utm_campaign=readme\">Get professional support for this package with a Tidelift subscription</a>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n","publish_time":1633335216738,"_cnpm_publish_time":1633335216738,"dist-tags":{"latest":"3.2.0"}}