I have a created library that has a script called "versionator": "node app.js"
inside package.json. But currently, other projects that download this library can only use it by importing the module as:
const versionator = require("versionator")
versionator()
Is there a way that i can run the script called "versionator" that is inside my library folder from another projects that download this lib?
What you need is to specify a bin
object inside your package.json
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin
{
"bin": {
"versionator": "./app.js"
}
}
This will create a bin called versionator.
Edit:
As CherryDT pointed out in his comment you can call it then via
npx versionator
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.