eyn
eyn

Reputation: 798

npm package.json defined bin module - command not found

I'm getting command not found... on a bin module I defined in my package.json. Why? I thought it was supposed to automatically map a local command into path.

In my module's package.json:

  "bin": {
    "testme": "./misc/testme"
  },

./misc/testme script:

#!/usr/bin/env node
console.log("this is a test");

It appears in the node_modules/.bin directory

$ ls node_modules/.bin
acorn       escodegen    gulp        kue-dashboard  ncp                 semver               stylus
cake        esgenerate   gzip-size   lessc          nopt                shjs                 testme
cleancss    esparse      handlebars  make-plural    pretty-bytes        sshpk-conv           uglifyjs
coffee      esvalidate   image-size  messageformat  rc                  sshpk-sign           user-home
dateformat  express      jade        mime           retrieve-arguments  sshpk-verify         uuid
dot-object  geojsonhint  jsonlint    mkdirp         rimraf              strip-indent         watchr
errno       grunt        js-yaml     mustache       sails               strip-json-comments  which

But, after npm install when I run it, I get:

$ testme
bash: testme: command not found...

Upvotes: 6

Views: 10892

Answers (3)

UchihaItachi
UchihaItachi

Reputation: 2752

There are 2 ways (that I can think of to run this command) :-

a(as told by @TAMAS) .

 npm install -g testme 

b.

 PATH = $PATH:/your/project/dir/node_modules/.bin
    
 EXPORT PATH

Upvotes: 2

forestbaba
forestbaba

Reputation: 317

For me, on Windows, had to run

npm link

in the root folder of my project before the commands begins executing. I don't know if it applies to other OS

Upvotes: 7

Tamas
Tamas

Reputation: 11244

I believe that running testme would only be possible if you'd install the package globally. In order to run this command (without the global installation) you'd have to npm run testme and add this to your package.json file:

"scripts": {
    "testme": "./bin/testme"

more info here: http://2ality.com/2016/01/locally-installed-npm-executables.html

Upvotes: 6

Related Questions