乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      package.json簡介

       流楚丶格念 2022-01-14

      文章目錄

      1、package.json簡介

      什么是Node.js的模塊(Module)?

      在Node.js中,模塊是一個庫或框架,也是一個Node.js項目。Node.js項目遵循模塊化的架構,當我們創(chuàng)建了一個Node.js項目,意味著創(chuàng)建了一個模塊,這個模塊的描述文件,被稱為package.json。

      通常情況下如果 package.json內容出錯,會導致項目出現(xiàn)bug,甚至阻止項目的運行。

      所以在修改該文件時候一定要小心,格式,名稱等是否正確

      2、package.json屬性說明

      • name - 包名.
      • version - 包的版本號。
      • description - 包的描述。
      • homepage - 包的官網(wǎng)URL。
      • author - 包的作者,它的值是你在https://網(wǎng)站的有效賬戶名,遵循“賬戶名<郵件>”的規(guī)則,例如:zhangsan zhangsan@163.com。
      • contributors - 包的其他貢獻者。
      • dependencies / devDependencies - 生產(chǎn)/開發(fā)環(huán)境依賴包列表。它們將會被安裝在 node_module 目錄下。
      • repository - 包代碼的Repo信息,包括type和URL,type可以是git或svn,URL則是包的Repo地址。
      • main - main 字段指定了程序的主入口文件,require('moduleName’) 就會加載這個文件。這個字段的默認值是模塊根目錄下面的 index.js。
      • keywords - 關鍵字

      上述參數(shù)是極為常見的參數(shù),另外還可以設置script、license等等。除了官方必須的一些參數(shù)外,我們也可以存儲我們自己的關于模塊的描述信息在package.json。

      3、生成package.json文件

      可以使用npm生成package.json文件,它可以包含最基本的設置以及結果。

      例如:運行

      npm init
      
      This utility will walk you through creating a package.json file.
      It only covers the most common items, and tries to guess sensible defaults.
      
      See `npm help json` for definitive documentation on these fields
      and exactly what they do.
      
      Use `npm install <pkg> --save` afterwards to install a package and
      save it as a dependency in the package.json file.
      
      Press ^C at any time to quit.
      name: (node_modules) runoob                   # 模塊名
      version: (1.0.0) 
      description: Node.js 測試模塊(www.xxxxx.com)  # 描述
      entry point: (index.js) 
      test command: make test
      git repository: https://github.com/xxxxx/xxxxx.git  # Github 地址
      keywords: 
      author: 
      license: (ISC) 
      About to write to ……/node_modules/package.json:      # 生成地址
      
      {
        "name": "runoob",
        "version": "1.0.0",
        "description": "Node.js 測試模塊(www.runoob.com)",
        ……# 其他參數(shù)
      }
      
      Is this ok? (yes)yes
      

      最后輸入yes

      這樣就生成了一個最基本的package.json文件。

      在這里插入圖片描述

      注意:

      手動更改的時候要完全遵循嚴格的JSON書寫格式,否則容易出現(xiàn)意想不到的簡單錯誤。

        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多