get-package-type
Advanced tools
Weekly downloads
Readme
Determine the package.json#type
which applies to a location.
const getPackageType = require('get-package-type');
(async () => {
console.log(await getPackageType('file.js'));
console.log(getPackageType.sync('file.js'));
})();
This function does not validate the value found in package.json#type
. Any truthy value
found will be returned. Non-truthy values will be reported as commonjs
.
The argument must be a filename.
// This never looks at `dir1/`, first attempts to load `./package.json`.
const type1 = await getPackageType('dir1/');
// This attempts to load `dir1/package.json`.
const type2 = await getPackageType('dir1/index.cjs');
The extension of the filename does not effect the result. The primary use case for this
module is to determine if myapp.config.js
should be loaded with require
or import
.
FAQs
Determine the `package.json#type` which applies to a location
The npm package get-package-type receives a total of 20,501,794 weekly downloads. As such, get-package-type popularity was classified as popular.
We found that get-package-type demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.