简体   繁体   中英

How to run a published npm package

I just published my first npm package.

Let's say the name of the package is auditor-connector. While developing the package, I was running it as npm start, and running the index.js file in it with certain arguments as follows.

npm run start arg1 arg2

I do know how to use this package in another project by install ing it, and require 'ing it.

However, is there a way, I can enable anyone to just run this package as a tool. Think of it as a tool I would like anyone to run, instead of a library, that I would like someone to use in code. I would expect something like the following npm run <name-of-package> <arg1> <arg2> since you would also have to specify the name of the package with the arguments it expects.

There's npx , the npm package manager. When you run

npx <name-of-package> <arg1> <arg2> ,

npx checks node_modules for the executable. If it's not there, npx downloads the package from npm and then executes it.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM