{"name":"parent-module","version":"3.1.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.1.0"},"devDependencies":{"ava":"^3.15.0","execa":"^5.1.1","tsd":"^0.17.0","xo":"^0.45.0"},"types":"./index.d.ts","gitHead":"f579e1737e12b120650997e16fef12dbced4938b","bugs":{"url":"https://github.com/sindresorhus/parent-module/issues"},"homepage":"https://github.com/sindresorhus/parent-module#readme","_id":"parent-module@3.1.0","_nodeVersion":"18.16.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-FX4TpKXX6CesSm1D9y5IcF0/KdDjP/w0c1AKqreGZne2QyWiPWHfoApMaJl8zvH3DTh+xtVmlLIUqSSoPYjqLQ==","shasum":"bcba90b465fa3ba029fad2a933f4c683668a2148","tarball":"http://registry-npm.ywwl.com/parent-module/download/parent-module-3.1.0.tgz","fileCount":5,"unpackedSize":4939,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDvbeJmShR+CeYeLE4/JA30I9wLHEXJNzmTZn1Am+FKjgIhANXOt3jeDgiLm8vngKrM1DdDxiNjVm4qIFxDkoHrfvQq"}],"size":2342,"noattachment":false,"key":"/parent-module/-/parent-module-3.1.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.1.0_1694672794314_0.07498039719627103"},"_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":1694672794494,"_cnpm_publish_time":1694672794494,"dist-tags":{"latest":"3.2.0"}}