npm 常用指令

2022-07-19 07:27:14 字數 789 閱讀 3476

npm install 安裝nodejs的依賴包

例如npm install express 就會預設安裝express的最新版本,也可以通過在後面加版本號的方式安裝指定版本,如npm install [email protected]

npm install -g  將包安裝到全域性環境中  對應的的是 package.json 檔案的 dependencies 

但是**中,直接通過require()的方式是沒有辦法呼叫全域性安裝的包的。全域性的安裝是供命令列使用的,就好像全域性安裝了vmarket後,就可以在命令列中直接執行vm命令

npm install --s  生產環境,將資訊寫入package.json中的 dependencies 

npm install --d  開發環境,將資訊寫入package.json中的 devdependencies 

專案路徑中如果有package.json檔案時,直接使用npm install方法就可以根據dependencies配置安裝所有的依賴包

這樣**提交到github時,就不用提交node_modules這個資料夾了。

npm init  會引導你建立乙個package.json檔案,包括名稱、版本、作者這些資訊等

npm remove 移除

npm update 更新

npm ls 列出當前安裝的了所有包

npm root 檢視當前包的安裝路徑

npm root -g  檢視全域性的包的安裝路徑

npm help  幫助,如果要單獨檢視install命令的幫助,可以使用的npm help install

npm 常用指令

npm install 安裝模組 npm uninstall 解除安裝模組 npm update 更新模組 npm outdated 檢查模組是否已經過時 npm ls 檢視安裝的模組 npm init 在專案中引導建立乙個package.json檔案 npm help 檢視某條命令的詳細幫助 np...

詳解npm的常用指令

首先我先給大家介紹一下npm的 這樣大家在學習的過程中可以邊看官網邊學習。官網 中文文件 npm是隨同nodejs一起安裝的包管理工具,能解決nodejs 部署上的很多問題,常見的使用場景有以下幾種 允許使用者將自己編寫的包或命令列程式上傳到npm伺服器供別人使用。說到npm的指令,大家可以檢視一下...

常用npm命令大全

生成package.json 啟動模組 檢視所有配置 檢視配置 刪除配置 設定配置,其中key有registry 源映象 proxy http proxy https proxy npm install 自動安裝devdependencies的外掛程式到node modules下 npm insta...