I'm working on an NPM package that is intended for use solely via npx *, a la packages like create-nuxt-app.
Is there a way to test my package with npx *? In other words, run my bin script without installing the package.
I've read this discussion, which suggests perhaps there isn't. I realise I can test the installation, rather than mere running, of my a packge via something like Yalc, but Yalc provides only yalc add *, which simulates npm install *, not npx *.
What's the best approach here?
After much digging and discussion it seems npm init * is identical to npx * provided the package name begins with create-. (Source).
So:
npx create-nuxt-app
is actually the same as
npm init nuxt-app
If your package doesn't begin with create- this won't work.
You can use either approach to pass args, if the package allows it.
This means you can use traditional NPM package testing mechanisms e.g. npm-link or something like Yalc, but test via npm * syntax rather than npx *.
I mean why don’t you just publish yow code to npm. Change the version of it
{
“name”:”yowPackage”,
“version”:”0.0.1-dev”,
…
}
then you can test yow package
$ npx yowPackage@0.0.1-dev arguments
Then once yow code works publish the oficial version
{
“name”:”yowPackage”,
“version”:”1.0.0”,
…
}
$ npx yowPackage@1.0.0 arguments
Check this to learn more about it