Achieve “npm run x” behavior without a “scripts” entry?

前端 未结 3 1143
我在风中等你
我在风中等你 2021-02-05 08:01

To run a node command within the \"context\" of your installed node_modules, you can make an entry in the scripts field of package.json.

3条回答
  •  被撕碎了的回忆
    2021-02-05 08:34

    I've saved this little script as ~/bin/npm-cmd on my computer:

    #!/bin/bash
    PATH="$(npm bin):$PATH" "$@"
    

    Then running npm-cmd PROGRAMARGS should look for PROGRAM in ./node_modules/.bin first, before falling back to normal lookup.

提交回复
热议问题