将 yeoman 项目推送到 github

Push yeoman project to github

我尝试与团队一起从事自耕农项目。使用 > yo angular 生成 angularjs 代码并将文件夹推送到 github

git add .
git push
git commit origin master

当我从 git github 克隆代码时出现此错误

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt hasn't been installed locally to your project. For more information about installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started

所以我删除了 .gitignore 中的所有内容并再次推送所有内容,我收到了这个警告

The file will have its original line endings in your working directory.

所以我很确定它不会起作用,也不是最好的方法。有人可以帮我上传 yeoman 项目吗?

首先,我认为你的问题有错别字,你混合了 commitpush 命令:

 git add .
 git commit -m 'commit message' // message is optional
 git push origin master

出现第一条消息是因为您没有安装 G运行t。 Install 它在您的工作目录中:

npm install grunt --save-dev

Starting with Grunt v0.4, you should never install Grunt itself globally. For more information about why, please read this. Source: grunt-cli docs.

如果它已经在 devDependencies 中列出,只需 运行:

npm install

第二个是由行尾引起的。在您的存储库中包含 .gitattributes 文件是一个好习惯。文件内容应为:

* text=auto

阅读此文件:docs. Or there is another method. It is described in this question

我认为 Yeoman 的 angular 生成器已经创建了一个 package.json 文件,其中 g运行t 定义为依赖项及其所有任务。因此,在克隆之后编译项目的正确方法是使用以下命令在本地安装所有 npm 依赖项:

npm install

然后 运行 g运行t 编译一切:

grunt

当然你必须全局安装g运行t-cli,在本地用来运行g运行t。要安装它,您必须使用以下命令,其中 -g 定义了全局安装(默认为本地):

npm install -g grunt-cli