zoukankan      html  css  js  c++  java
  • 全局添加可执行的node脚本

    在本地  npm 包项目下 package.json 文件中添加脚本

    {
      "name": "winyh",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "bin": "bin/run",
      "scripts": {
        "test": "echo "Error: no test specified" && exit 1"
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "dependencies": {}
    }
    

      

    {
      ...
     "bin": "bin/run"
     ...
    }
    

      

    创建目录bin, 并在bin中创建文件run,这便是本地npm包的可执行文件。

    编辑run 文件

    #!/usr/bin/env node
    
    console.log('winyh script run success!');
    

      

    包根目录执行(链接)命令

    npm link
    

      

    此时,在任意一个位置终端里执行以下命令都可以看到输出  winyh script run success!

    winyh
    

      

  • 相关阅读:
    日期时间插件
    QQ在线客服
    dede轮播图
    Animation 案例解释
    transition Css3过度详解
    解决文字无法缩小的问题
    DEDE函数
    hdu 3435 图回路分割
    HDU 4183
    hdu 1569 最小割
  • 原文地址:https://www.cnblogs.com/winyh/p/14081642.html
Copyright © 2011-2022 走看看