zoukankan      html  css  js  c++  java
  • [Whole Web] [Node.js] Using npm run to launch local scripts

    npm run allows you to configure scripts inside of your package.json file which can access locally installed node packages. If you're comfortable with this technique, you can also grunt, gulp, or other build tools by customizing your scripts and saving them inside of your package.json file. With this approach, when a developer starts a new project with your package.json, they can simply runnpm install then npm run yourscript without having to install any node packages globally.

    For example:

    If you haven't installed browserify globally, and you use npm to install it locallly:

    npm install browserify --save-dev

    Then you create a test script to run browserify:

      "scripts": {
        "test": "echo "Error: no test specified" && exit 1",
        "demo": "echo Hello World!",
        "b_version": "browserify -v"
      },

    You run on tml:

    npm run b_version

    You will get the version number, but if you type in tml:

    browserify -v

    You will get error, because you haven't installed it globally, which means that I can use npm run to invoke anything I've installed locally without forcing my users to say "npm install -g" to install things globally, Which means with this approach, you could just include a package file in your project, say "npm install" to get everything installed locally, and then npm run whatever task you want to set up, whether it's browserify or whatever. Then it can just grab those locally installed modules and run them.

    More: 

    https://egghead.io/lessons/nodejs-using-npm-run-to-launch-local-scripts#/tab-transcript

  • 相关阅读:
    实现毛玻璃效果
    iOS-调用系统的短信和发送邮件功能,实现短信分享和邮件分享
    集成环信
    HTTP 方法:GET 对比 POST
    虚拟DOM
    javascript的回调函数 同步 异步
    jQuery中的Deferred和promise
    web性能
    JSONP
    java
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4339915.html
Copyright © 2011-2022 走看看