<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 隱式調用node執行程序 前面我們在執行`node`程序的時候都是使用`node filePath`(比如,`node index`)的形式。但是,對于命令行程序,像`npm,git`,你在命令行使用這些命令行程序時,前面不會再帶一個執行程序名稱,而我們在[命令行參數處理](313192)這一小節使用自定義命令參數時,需要使用形如`node index exec`的命令,這個過程很繁瑣,這一小節將介紹如何簡化這個過程。 1.創建一個`node`工程(創建文件夾,將工作目錄切換到文件加,`npm init`生成`package.json`,創建`index.js`文件) 2.打開`index.js`文件,輸入下面內容: ~~~ #!/usr/bin/env node console.log('Hello,world!'); ~~~ 我們在最前面加了`#!/usr/bin/env node`,它的作用是指定`index.js`的執行程序`node`,這時,你可以使用` ./index.js `直接執行`index.js`文件了。 3.雖然我們將第一個參數`node`去掉了,但是`index.js`這個文件名稱太普遍了,并且,如果不在`index.js`的工作目錄下,執行`index.js`的時候還要輸入相對`index.js`的路徑,這個過程很繁瑣,我們需要更簡單的方法。 下面介紹解決方案: 1)打開`package.json`文件,加入一個字段`bin`,如下: ~~~ "bin":{ "mymodule":"./index.js" }, ~~~ 這里`mymodule`你可以自定義,如果是準備發布的模塊,一般會使用模塊名稱,如果是本地使用,你開心就好。 package.json完整文件如下: ~~~ { "name": "hello_module_outsider", "version": "1.0.0", "description": "My first node module", "main": "index.js", "bin":{ "mymodule":"./index.js" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ "hello", "module" ], "author": "outsider", "license": "ISC" } ~~~ 2)在當前工作目錄下執行`npm link`,把模塊鏈接的本地`npm`倉庫 至此,我們可以完全使用 `mymodule`來替代`node index.js`了,而且,這個它是全局的,你可以在任何目錄下使用。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看