Build yeoman project from git checkout

吃可爱长大的小学妹 提交于 2019-12-21 02:42:09

问题


Am facing issue in building the yeoman project checkout from git. Am trying to take git checkout of yeoman project and run grunt serve. Following is the scenario followed by error description

Scenario description :

Person1 created the yeoman angularjs project using yo angular. grunt serve is working fine in Person1's computer. Person1 pushes the code to git so other team members can work on it.

Problem occurs when Person2 takes a checkout of the git (git clone < URL>). The grunt serve command in the checked out copy will give following error :

$ 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

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

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.


回答1:


Execute a simple npm install inside the App-Directory.

The Problem is: The Yeoman-Projcet has lots of npm-dependencies, not only grunt itself, but also all of grunts tasks and generators. 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. npm install reads the package.json and installs all needed packages by itself.

To run the app properly, you will also need to execute bower install. Bower is for the Frontend-Packages what npm is for node. "bower install" looks for the dependent packages in the "bower.json"-File and installs them.




回答2:


Solved in 2 steps. The the following commands :

  1. npm install
  2. bower install

Now run grunt serve

$ 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 :)



来源:https://stackoverflow.com/questions/22376185/build-yeoman-project-from-git-checkout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!