{"id":21565130,"url":"https://github.com/cfware/get-package-type","last_synced_at":"2025-08-03T11:03:55.109Z","repository":{"id":57250354,"uuid":"264761858","full_name":"cfware/get-package-type","owner":"cfware","description":"Determine the `package.json#type` which applies to a location.","archived":false,"fork":false,"pushed_at":"2020-05-19T10:06:23.000Z","size":9,"stargazers_count":5,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T13:38:30.121Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cfware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-17T21:40:11.000Z","updated_at":"2022-09-02T06:01:02.000Z","dependencies_parsed_at":"2022-08-24T16:22:29.412Z","dependency_job_id":null,"html_url":"https://github.com/cfware/get-package-type","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fget-package-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fget-package-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fget-package-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fget-package-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cfware","download_url":"https://codeload.github.com/cfware/get-package-type/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248224820,"owners_count":21068075,"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-11-24T10:18:31.897Z","updated_at":"2025-04-10T13:09:39.507Z","avatar_url":"https://github.com/cfware.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# get-package-type [![NPM Version][npm-image]][npm-url]\n\nDetermine the `package.json#type` which applies to a location.\n\n## Usage\n\n```js\nconst getPackageType = require('get-package-type');\n\n(async () =\u003e {\n  console.log(await getPackageType('file.js'));\n  console.log(getPackageType.sync('file.js'));\n})();\n```\n\nThis function does not validate the value found in `package.json#type`.  Any truthy value\nfound will be returned.  Non-truthy values will be reported as `commonjs`.\n\nThe argument must be a filename.\n```js\n// This never looks at `dir1/`, first attempts to load `./package.json`.\nconst type1 = await getPackageType('dir1/');\n\n// This attempts to load `dir1/package.json`.\nconst type2 = await getPackageType('dir1/index.cjs');\n```\n\nThe extension of the filename does not effect the result.  The primary use case for this\nmodule is to determine if `myapp.config.js` should be loaded with `require` or `import`.\n\n[npm-image]: https://img.shields.io/npm/v/get-package-type.svg\n[npm-url]: https://npmjs.org/package/get-package-type\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfware%2Fget-package-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcfware%2Fget-package-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfware%2Fget-package-type/lists"}