zkat / npx

execute npm package binaries (moved)
https://github.com/npm/npx
Other
2.63k stars 105 forks source link

How to specify local package with `file:`? #201

Closed doowb closed 6 years ago

doowb commented 6 years ago

The readme says that I can specify a local directory but doesn't give any examples on how to do it. I've tried using the same syntax that would be used in package.json for dependencies, but that's not working:

$ npx file:../../../some-folder/some-package
ENOENT: no such file or directory, stat 'file:../../../some-folder/some-package'

I've looked at different places in the code to see if there was another way to specify it, but it looks like the raw spec is being passed as the command instead of a resolved spec. I've also tried passing in the specific file used in the bin folder, but that doesn't work either.

I'm using npm 6.1.0 on mac osx.

danieleloscozzese commented 6 years ago

Hi @doowb, I just happened to come across this. I've been able to execute local packages by passing the directory path directly to npx, like:

$ npx ../../some-package

The some-package directory is the root of an npm package, in this case.

I think that's what's meant in the README when it says local directories for All package specifiers understood by npm may be used with npx.

Does that help you?

doowb commented 6 years ago

Thanks @DanArthurGallagher. I tried that and I get:

$ npx ../../../some-folder/some-package
command not found: ../../../some-folder/some-package

However, this did work for me:

$ npx ../../../some-folder/some-package/bin/cli.js

I had tried that before using the file: specifier but it didn't work. Thanks for the suggestion to get me to the correct place.