問題描述
有什麼東西可以跟踪我安裝的 npm 包並在不同的開發環境中恢復它們嗎?(如“恢復 NuGet 包”) (Is there anything that can keep track of my installed npm packages and restore them on a different dev environment ? (like "Restore NuGet packages"))
所以我是 node/npm 包的新手。這是場景。
- 我在一個環境中安裝了所有依賴項。
- 將代碼推送到遠程倉庫
- 將代碼拉到不同的開發環境。
- 嘗試自動恢復所有以前安裝的依賴項,但無法想辦法。
我以前使用過 NuGet 包。我期待類似於 “恢復 NuGet 包”的行為。我查看了我的 packages.json 文件,但他們沒有t 列出以後安裝的依賴項,如 packages.config 文件在 NuGet 的情況下會執行。那麼有沒有類似的呢?還是缺少什麼?
參考解法
方法 1:
The package.json
file is doing what you are looking for. Installing a dependency with ‑‑save
option will add it to the package.json
dependency list. On another environment you can install same dependencies with running npm install
command.
- Install a dependency for the first time:
npm install newpackage ‑‑save
- Push the
package.json
to the repo - Pull the repo
- Install all dependencies which listed in package.json file by running
npm install
command in the directory whichpackage.json
reside
(by Foez Ahmed、saman.shahmohamadi)