2017-05-19 153 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