0

I am trying to create an executable for use with npx. I have package.json with the relative information like so -

 ...
 "name": "@company/example-command",
 "bin": {
    "example-command": "./dist/index"
  },
  "scripts": {
    "prepare": "tsc && chmod +x ./dist/index.js"
  },
  ...

Everything publishes correctly to the Github registry. However, upon invocation,

npx @company/example-command

I am getting an error

no such file or directory, chmod /path/to/npx/modules/@company/example-command/dist/index

This seems to indicate that npx is finding the correct command and downloading the relevant package, but the executable is not added to the path.

My hunch is that I need to compile the typescript lib to dist before invoking the file (tsc && ./dist/index), but I assumed that prepare would handle the set-up of the dist.

What is the proper way to make this Typescript lib into a bin that is executable by npx?

nrako
  • 2,952
  • 17
  • 30

1 Answers1

0

.bin path is not in a node context, so it needed the explicit .js extension

"example-command": "./dist/index.js"
nrako
  • 2,952
  • 17
  • 30