简体   繁体   English

NPM使用Git Clone安装

[英]NPM Install with Git Clone

I have a nodejs project on GitHub. 我在GitHub上有一个nodejs项目。 I use git clone ${GitHubUrl} to clone it for development. 我使用git clone ${GitHubUrl}来克隆它以进行开发。 I use npm install ${GitHubUrl} or npm update for production use. 我使用npm install ${GitHubUrl}npm update进行生产使用。

git clone sets up a git repo for development/committing, however it does not install package dependencies. git clone为开发/提交设置了一个git repo,但它没有安装包依赖项。

npm install installs package dependencies, however it does not set up a git repo for developing or committing. npm install安装包依赖项,但它没有为开发或提交设置git repo。

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_modules into the git repo, but that has obvious disadvantages. 这里一个可行的解决方案可能是将./node_modules提交到git ./node_modules ,但这有明显的缺点。

@SLaks has the right answer. @SLaks有正确的答案。

git clone foo && cd foo && npm i

I did not realize npm install with no additional arguments installs the local package.json file. 我没有意识到npm install没有附加参数安装本地package.json文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM