Grunt服务器不工作在nitrous.io
我使用nitrous.io创build了一个节点env。 在他们的terminal里面,我安装了文员。 如果我尝试运行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或“本地主机”更改为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服务器,以便我可以在浏览器中看到我的网站?
总结这个工作给我的评论:
gem install sass; gem install compass yo webapp
在第43行编辑Gruntfile.js
:
connect: { options: { port: 3000, // <- changed this line livereload: 35729, hostname: '0.0.0.0' // <- changed this line
运行grunt server
并点击PreviewButton / Port 3000 。
你有没有通过你得到的第一个错误消息的build议? 你需要Gruntfile.js
和package.json
(将Grunt列为依赖项); 这在官方文档中有介绍 。 然后,通过运行npm install
您将能够将当地的Grunt拖放到您的项目中。