2017-05-19 426 views
0

我得到command not found...上的bin模塊我在我的package.json中定義了模塊。 爲什麼?我認爲它應該自動將本地命令映射到路徑中。npm package.json已定義的bin模塊 - 找不到命令

在我模塊的package.json:

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

./misc/testme腳本:

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

它出現在node_modules/.bin文件目錄

$ 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 

但是,當我運行它時npm install,我得到:

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

回答

1

有2種方式(即我可以想到運行這個命令): -

a(正如@TAMAS所說的)。

npm install -g testme 

b。

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

EXPORT PATH