我使用nitrous.io创建了一个节点env。在他们的终端内部我安装了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服务器,以便我可以在broswer中看到我的网站?
答案 0 :(得分:1)
您是否看过第一条错误消息的建议?您需要Gruntfile.js
和package.json
(将Grunt列为依赖项); this is covered in the official documentation。然后,通过运行npm install
,您将能够将本地Grunt下载到您的项目中。
答案 1 :(得分:0)
总结一下这对我有用的评论:
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
并点击预览 -Button / 端口3000 。