6

在从 git 构建 yeoman 项目结账时面临问题。我正在尝试对 yeoman 项目进行 git checkout 并运行grunt serve。以下是错误描述的场景

场景描述:

Person1使用yo angular创建了 yeoman angularjs 项目。grunt servePerson1的计算机上运行良好。Person1将代码推送到 git,以便其他团队成员可以处理它。

Person2签出 git ( git clone < URL> ) 时会出现问题。签出副本中的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

我试过了 :npm install grunt

我收到以下错误:

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.

使用的工具 :

$ 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 在目录上

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

我需要帮助来完成从 git checkout 构建项目的任务,以便我可以继续开发。

4

2 回答 2

9

npm install在 App-Directory 中执行一个简单的操作。

问题是:Yeoman-Projcet 有很多 npm 依赖项,不仅是 grunt 本身,还有所有 grunt 任务和生成器。但是你当然不希望所有这些包都在你的存储库中。那是“package.json”文件进来:它列出了项目所依赖的所有包。npm install读取 package.json 并自行安装所有需要的包。

要正确运行应用程序,您还需要执行bower install. Bower 用于前端包,就像 npm 用于节点一样。“bower install”在“bower.json”文件中查找依赖包并安装它们。

于 2014-03-13T10:56:30.480 回答
6

分两步解决。以下命令:

  1. npm 安装
  2. 凉亭安装

现在运行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...

这解决了问题。

让我知道这是否可以避免或以更好的方式完成:)

于 2014-03-13T10:56:56.947 回答