简体   繁体   English

从git checkout构建yeoman项目

[英]Build yeoman project from git checkout

Am facing issue in building the yeoman project checkout from git. 我正面临着从git建立yeoman项目结账的问题。 Am trying to take git checkout of yeoman project and run grunt serve . 我试图采取自定义项目的git结帐并运行grunt服务 Following is the scenario followed by error description 以下是错误描述后面的方案

Scenario description : 场景描述:

Person1 created the yeoman angularjs project using yo angular . Person1使用yo angular创建了yeoman angularjs项目。 grunt serve is working fine in Person1 's computer. grunt servePerson1的计算机上工作正常。 Person1 pushes the code to git so other team members can work on it. Person1将代码推送到git,以便其他团队成员可以使用它。

Problem occurs when Person2 takes a checkout of the git ( git clone < URL> ). Person2结帐git时会出现问题( git clone <URL> )。 The grunt serve command in the checked out copy will give following error : 签出副本中的grunt serve命令将给出以下错误:

$ grunt serve
grunt-cli: The grunt command line interface. (v0.1.13)

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

I tried : npm install grunt 我试过了: npm install grunt

I got the following error : 我收到以下错误:

grunt serve
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'load-grunt-tasks'
Warning: Task "serve" not found. Use --force to continue.

Aborted due to warnings.

Tools Used : 使用的工具 :

$ grunt -version
grunt-cli v0.1.13
grunt v0.4.4
$ yo -v
1.1.2
suraj@localhost:testing$ npm -version
1.4.4

ls -l on the directory ls -l在目录上

drwxrwxr-x app
-rw-rw-r-- bower.json
-rw-rw-r-- Gruntfile.js
-rw-rw-r-- karma.conf.js
-rw-rw-r-- karma-e2e.conf.js
drwxrwxr-x node_modules
-rw-rw-r-- package.json
drwxrwxr-x test

I need help in accomplishing the task of building the project from git checkout so I could carry on the development. 我需要帮助完成从git checkout构建项目的任务,所以我可以继续开发。

Execute a simple npm install inside the App-Directory. 在App-Directory中执行简单的npm install

The Problem is: The Yeoman-Projcet has lots of npm-dependencies, not only grunt itself, but also all of grunts tasks and generators. 问题是:Yeoman-Projcet有很多npm依赖,不仅是grunt本身,还有所有grunts任务和生成器。 But of course you wouldnt want all those packages inside your repository. 但是,当然你不希望你的存储库中的所有这些包。 Thats were the "package.json" File comes in: It Lists alls Packages the Project depents on. 这就是“package.json”文件的来源:它列出了项目所依赖的所有包。 npm install reads the package.json and installs all needed packages by itself. npm install读取package.json并自行安装所有需要的包。

To run the app properly, you will also need to execute bower install . 要正确运行应用程序,您还需要执行bower install Bower is for the Frontend-Packages what npm is for node. Bower用于Frontend-Packages,npm用于节点。 "bower install" looks for the dependent packages in the "bower.json"-File and installs them. “bower install”在“bower.json”-File中查找依赖包并安装它们。

Solved in 2 steps. 解决了两个步骤。 The the following commands : 以下命令:

  1. npm install npm安装
  2. bower install 凉亭安装

Now run grunt serve 现在运行grunt服务

$ grunt serve
Running "serve" task

Running "clean:server" (clean) task

Running "bower-install:app" (bower-install) task

Running "concurrent:server" (concurrent) task

    Running "compass:server" (compass) task
    directory .tmp/styles/ 
       create .tmp/styles/main.css (8.454s)
    Compilation took 8.455s

    Done, without errors.


    Execution Time (2014-03-13 10:53:01 UTC)
    compass:server  9.1s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100%
    Total 9.1s

Running "autoprefixer:dist" (autoprefixer) task
Prefixed file ".tmp/styles/main.css" created.

Running "connect:livereload" (connect) task
Started connect web server on 127.0.0.1:9000.

Running "watch" task
Waiting...

This solves the problem. 这解决了这个问题。

Let me know if this can be avoided or done in better way :) 让我知道这是否可以避免或以更好的方式完成:)

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

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