如何用grunt构建骨干样板?

时间:2013-09-27 19:35:46

标签: javascript backbone.js backbone-boilerplate

我正在尝试构建这里找到的骨干样板项目:https://github.com/backbone-boilerplate/backbone-boilerplate

我有一些问题需要它才能正确构建。以下是我已经完成的步骤,这些步骤是关于backbone-boilerplate wiki的步骤:

git clone https://github.com/backbone-boilerplate/backbone-boilerplate.git
cd backbone-boilerplate
sudo npm install -gq bower
sudo npm install -q
sudo npm install -gq grunt-cli
sudo grunt

此时我得到:

>> Local Npm module "grunt-cli" not found. Is it installed?
Warning: Task "requirejs" not found. Use --force to continue.

Aborted due to warnings.

任何想法如何正确构建?

3 个答案:

答案 0 :(得分:0)

指定深度似乎有效:

$ git clone --depth 1 https://github.com/backbone-boilerplate/backbone-boilerplate.git
$ npm install
$ grunt

如果您是第一次安装grunt-cli

,也可能需要重新启动终端

答案 1 :(得分:0)

您正在以提升的权限运行grunt。我们在这里建立的文档:

https://github.com/backbone-boilerplate/backbone-boilerplate#build-process

...您是否在自己的用户下运行该命令。试一试!

答案 2 :(得分:0)

您需要确保使用bower构建依赖关系,而不仅仅是节点依赖关系。

使用入门

# Using Git, fetch only the latest commits.  You won't need the full history
# for your project.
git clone --depth 1 https://github.com/backbone-boilerplate/backbone-boilerplate

# Move the repository to your own project name.
mv backbone-boilerplate my-project

更新依赖关系

# Install global dependencies.  Depending on your user account you may need to
# gain elevated privileges using something like `sudo`.
npm install -g grunt-cli bower

# Optionally install coveralls (integration is baked in with Travis CI).
npm install -g coveralls

# Install NPM dependencies.
npm install

# Install Bower dependencies. ** THIS IS THE ONE YOU'VE MISSED **
bower install

构建流程

# To run the build process, run the default Grunt task.
grunt

# Run a build and test the now optimized assets.
grunt default server:release

如果您正确安装了节点,这应该像魅力一样。