1. 程式人生 > >npm學習筆記——初識npm文件

npm學習筆記——初識npm文件

npm 學習筆記

一、初識npm文件

1.1  npm是啥?

     npm 是 Node 的模組管理器,它是 Node 獲得成功的重要原因之一。
     官方文件翻譯:npm是世界上最大的軟體註冊機構,開源開發人員使用npm來共享和借用包,許多組織也使用npm來管理私有開發;包括web、cli、registry三個部分
web——可以搜尋包,管理個人資訊和包管理等
cli——執行在命令列,程式猿和npm進行互動
 registry——JS包大型公共資料庫(npm 模組倉庫提供了一個查詢服務)

 

1.2 用npm 可以幹啥?

 - 管理自己程式碼的包
 - 不需要npx即可執行包
 - 分享程式碼
 - 建立組織協調包維護,編碼和開發人員。
 - 管理程式碼版本和依賴
 - 當底層程式碼更新時可以輕鬆更新應用程式。

1.3 package和nodemodules

區別:官方解釋:
> package:A package is a file or directory that is described by a package.json file.
> nodeModule:A module is any file or directory in the node_modules directory that can be loaded by the Node.js *require()* function.   To be loaded by the Node.js *require()* function, a module must be **one of the following**:
         1.A folder with a package.json file containing a "main" field.
         2.A folder with an index.js file in it.
         3.A JavaScript file.(module 參考Node.js 模組)
注意:因為modules

不要求有 package.json, 所以不是所有的 modules都是package. 只有modules 有package.json檔案才是package.
>scopes:scopes允許您建立與其他使用者/組織建立的包具有相同名稱的包,而不會發生衝突。