find-entry-point
v1.6.2
Published
Find npm module entry point
Downloads
2,684
Readme
Find the entry point of a Node module via the command line or programmatically.
Quick start
npx find-entry-point <modulename>
Install
npm install find-entry-point -g
Usage
Command Line
$> find-entry-point <modulename>
Programmatically
const {findPackageEntryPoint} = require("find-entry-point")
import {findPackageEntryPoint} from "find-entry-point"
Examples
For Js code
const entryPoint = findPackageEntryPoint("to-ansi")
console.log(entryPoint)
// C:\path\to\node_modules\to-ansi\index.cjs
const entryPoint = findPackageEntryPoint("to-ansi", "some-dir/")
For command line
$> find-entry-point --name strip-comments-strings
/projects/find-entry-point/node_modules/strip-comments-strings/index.mjs
$> find-entry-point --name to-ansi --path /projects/some-project-path
/projects/to-esm/node_modules/to-ansi/index.mjs
$> find-entry-point --name to-ansi --path /projects/some-project-path --target cjs
/projects/to-esm/node_modules/to-ansi/index.cjs
$> find-entry-point --name to-ansi --path /projects/some-project-path --target esm
/projects/to-esm/node_modules/to-ansi/index.mjs
$> find-entry-point --name my-module --path /projects/some-project-path --target browser
/projects/to-esm/node_modules/my-module/index.js
$> find-entry-point --name to-ansi
$> find-entry-point to-ansi
$> find-entry-point node_modules/to-ansi
$> find-entry-point which
$> find-entry-point node_modules/which
$> find-entry-point ../clonefile/node_modules/rimraf
$> find-entry-point --name which --path ../clonefile
$> find-entry-point --name ./
$> find-entry-point --name ./ --target esm
$> find-entry-point --name ./ --target browser
Options
For Js code
| Options | Description | Expect | default | |-------------|----------------------------------------------------------------------------------|-------------|---------| | silent | For hiding messages | boolean | false | | exception | For hiding errors | boolean | false | | isBrowser | To detect entry point for browser environment (takes precedence over isModule) | boolean | false | | isModule | To detect entry point for ESM environment | boolean | true | | isCjs | To detect entry point for CommonJs environment | boolean | false | | noAnsi | To display errors without ansi colors | boolean | false | | noAmbiguous | To prevent looking for ambiguous/non standard enough entrypoint | boolean | false |
For command line
| Options | Description | Expect | default | |---------------|-----------------------------------|---------------------|---------| | --silent | For hiding messages | boolean | false | | --exception | For hiding errors | boolean | false | | --target | To force environment | browser,esm,cjs | browser | | --noAnsi | To disable ANSI symbols | boolean | false | | --noAmbiguous | To prevent ambiguous entrypoint | boolean | false |
License
Package
📁 package
│
└───📁 cjs
│ │
│ │─ 📝 find-entry-point.cjs ⇽ CJS version - Node (8.93k unminified)
│ │
└───📁 esm
│ │
│ │─ 📝 find-entry-point.mjs ⇽ ESM version - Node (8.94k unminified)
│ │
└───📁 build
│ │
│ │─ 📝 find-entry-point.min.cjs ⇽ CJS version - Node (9.36k minified)
│ │─ 📝 find-entry-point.min.mjs ⇽ ESM version - Node (8.74k minified)
Changelog
- Add a --noAmbiguous option for skipping ambiguous entrypoint
- Fix undefined variable js error