javascript 使用 Git Clone 安装 NPM

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45846097/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 06:17:21  来源:igfitidea点击:

NPM Install with Git Clone

javascriptnode.js

提问by GreenFox

I have a nodejs project on GitHub. I use git clone ${GitHubUrl}to clone it for development. I use npm install ${GitHubUrl}or npm updatefor production use.

我在 GitHub 上有一个 nodejs 项目。我git clone ${GitHubUrl}用来克隆它进行开发。我使用npm install ${GitHubUrl}npm update用于生产用途。

git clonesets up a git repo for development/committing, however it does not install package dependencies.

git clone为开发/提交设置一个 git repo,但它不安装包依赖项。

npm installinstalls package dependencies, however it does not set up a git repo for developing or committing.

npm install安装包依赖项,但它不会设置用于开发或提交的 git 存储库。

Is there a command that combines these two? Surely this is a fairly common workflow and someone has a better solution for this. Perhaps something like git clone ${GitHubUrl}then some npm command?

有没有结合这两者的命令?当然,这是一个相当常见的工作流程,有人对此有更好的解决方案。也许像git clone ${GitHubUrl}一些 npm 命令?

A workable solution here could be commit ./node_modulesinto the git repo, but that has obvious disadvantages.

一个可行的解决方案是提交./node_modules到 git repo,但这有明显的缺点。

回答by GreenFox

@SLaks has the right answer.

@SLaks 有正确的答案。

git clone foo && cd foo && npm i

git clone foo && cd foo && npm i

I did not realize npm installwith no additional arguments installs the local package.jsonfile.

我没有意识到npm install没有额外的参数安装本地package.json文件。