先端開発必須——NPM

1673 ワード

紹介する
  • NPMはnode.jsに基づいて開発されたソフトウェア
  • である.
  • NPMはnode.jsデフォルトパッケージ管理ツールであり、現代のフロントエンド開発には
  • が必要である.
    NPMが正常にインストールされているかどうかを確認
    npm -v

    NPMミラーNPM は海外にあるため、ダウンロード速度が遅く不安定なため、国内のミラーに切り替える必要がある(国内で最も有名なミラーはアリの)
  • NPM現在のミラーを表示する
  • npm config get registry
  • ミラー
  • を設定する.
    npm config set registry https://registry.npm.taobao.org
  • [ ] nrmミラー管理ツール
  • //   
    npm i nrm -g --registry=https://registry.npm.taobao.org
    
    //                
    nrm ls
    
    //     
    nrm use taobao

    NPMの更新方法
    // npm           
    npm i npm -g

    きほんしよう
  • 取付
  • //     
    npm i xxx
    npm i xxx -S
    npm i [email protected] -S
    
    //     
    npm i xxx -D
    
      :
    1、     
    2、       ,     package.json         
  • アンインストール
  • //     
    npm uninstall xxx -g
    
    //     
    npm uninstall xxx -D
    
    //     
    npm uninstall xxx -S
  • 更新
  • //        
    npm update -g 
    
    //       
    npm update -g xxx
    
    //        
    npm update 
    
    //       
    npm update xxx
    
      :
    1、   package.json         
  • を表示
    //       
    npm ls -g xxx
    
    //       
    npm ls xxx
    
    //            
    npm ls

    package.json詳細(NPMプロファイル)
    プロジェクトでNPMインストールパッケージの使用方法
    npmがインストールしたパッケージはすべてnode_に保存されています.moudulesフォルダ
  • 導入方式
  • // node.js ,  CommonJS      
    const $ = require('jquery');
    
    // webpack ,    CommonJS ES6     
    import $ from 'jquery';
    const $ = require('jquery');
    
      :webpack   ,CommonJS       ES6      ,ES6       CommonJS      
  • 導入経路
  • 接尾辞
  • を導入