1

我使用nitrous.io创建了一个节点环境。在他们的终端内,我安装了yeoman。如果我尝试运行,grunt server我会收到一条错误消息:

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

如果我去预览而不是连接到端口 3000 我得到这个

错误信息

节点的参考状态将 127.0.0.1 或“localhost”更改为 0.0.0.0

  var http = require('http');
  http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
  }).listen(3000, '0.0.0.0');
  console.log('Server running at http://0.0.0.0:3000/');

服务器的 Grunt 语法有点不同

connect: {
      options: {
        port: 3000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: '0.0.0.0' // 
      },

即使在此更改之后,错误仍然存​​在。grunt server当我运行或去预览端口 3000时失败

关于我做错了什么的任何想法?如何运行我的 grunt 服务器以便在浏览器中看到我的站点?

4

2 回答 2

1

对于收到的第一条错误消息,您是否仔细阅读过建议?你需要Gruntfile.jspackage.json(将 Grunt 列为依赖项);这在官方文档中有介绍。然后,通过运行,npm install您将能够将本地 Grunt 下拉到您的项目中。

于 2013-09-07T16:21:02.677 回答
0

总结一下这对我有用的评论:

gem install sass; gem install compass
yo webapp

编辑Gruntfile.js第 43 行:

connect: {
  options: {
    port: 3000, // <- changed this line
    livereload: 35729,
    hostname: '0.0.0.0' // <- changed this line

运行grunt server并单击Preview -Button / Port 3000

于 2013-11-04T11:50:06.923 回答