zkat / npx

execute npm package binaries (moved)

Home Page:https://github.com/npm/npx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to specify local package with `file:`?

doowb opened this issue · comments

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.

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?

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.